views:

722

answers:

3

Well I have an application that uses both Objective C & c++ but for portability reasons I have tried to use c++ as much as possible.... Now I am confronted with some problem that requires threads I was thinking of using pthread instead of NSThread.... is it Okay to use pthread... will Apple punish me for using it by rejecting my app on the appstore...?

Your comments please......

+3  A: 

NSThread is built around pthread anyway

I can't see any reason why using pthread would lead to rejection from Apple's part

Gregory Pakosz
Yes. In fact, there's no problem creating a thread using pthreads and invoking [NSThead currentThread] from that thread to get the NSThread version of the pthread or similarly, calling pthread_self from any NSThread created thread.
Matt Gallagher
+1  A: 

My app uses pthread API, changes the scheduling policy from SCHED_OTHER to SCHED_FIFO, and changes thread's priority. It works well.

However, I avoid using Cocoa touch framework APIs in the thread because I don't know the side effect of pthread instead of NSThread.

KatokichiSoft
+1  A: 

NSThread is mostly a wrapper around pthread semantics.

Advantages: - NSThreadWillExitNotification notification when NSThread exits - A NSMutableDictionary thread-local storage

Limitations: - you can only create detached NSThread

Be aware that Cocoa needs to know that you want to do multi-threading. It is important to first detach a dummy NSThread so the application can be considered multi-threaded.

Laurent Etiemble