hakuna matata
hakuna matata

Reputation: 3327

Interrupting and Joining NSThread

I want to do interrupt and join on an instance of NSThread like I do in Java. I have read the NSThread Class Reference but I can't find such methods. What can I do to have the same effect?

Upvotes: 0

Views: 1128

Answers (1)

Stunner
Stunner

Reputation: 12194

Not sure if that is possible with NSThreads...

In the concurrency programming guide there is a mention of replacing thread joins(see Replacing Thread Joins Section with GCD (Grand Central Dispatch). There is also a mention about getting NSOperations to wait on each other here (scroll all the way down to Waiting for Operations to Finish).

In the Threading Programming Guide, under section Setting the Detached State of a Thread Apple mentions the following:

If you do want to create joinable threads, the only way to do so is using POSIX threads. POSIX creates threads as joinable by default. To mark a thread as detached or joinable, modify the thread attributes using the pthread_attr_setdetachstate function prior to creating the thread. After the thread begins, you can change a joinable thread to a detached thread by calling the pthread_detach function. For more information about these POSIX thread functions, see the pthread man page. For information on how to join with a thread, see the pthread_join man page.

Upvotes: 4

Related Questions