What is the equivalent of C # 'Thread.Join ()' in Cocoa?

I am making an iPhone application using threads. For some time I used C #, there was a method Thread.Join()that blocks the current thread to perform specific thread terminations. What is equivalent in Cocoa for this? Or alternatives?

--- edit ---

PS. I am using NSThread.

--- edit ---

I find a method like "waitForThreadExit" that blocks the thread of the caller until the thread completes execution.

+3
source share
4 answers

NSThread Join . NSThread - , , . , . . "" ( Join, ), pthreads, NSThread (, NSCondition).

+1

, Cocoa, . NSThread POSIX . :

joinable , : POSIX. POSIX . , , pthread_attr_setdetachstate . , pthread_detach . POSIX, . pthread man page. , . pthread_join.

NSThread, NSThreadWillExitNotification.

+4

pthreads, : pthread_join.

, NSThread, join , .

NSObject SelectorOnMainThread: withObject: waitUntilDone:

, .

Apple.

+1

You can do it yourself using NSConditionLock. Define two conditions: start and end. The worker thread receives a "run" lock and, upon completion, is unlocked with the "completed" condition. Then the connection will be to fix the “completed” lock and then unlock it “completed”.

0
source

Source: https://habr.com/ru/post/1731760/


All Articles