开发者

Wait and notify equivalent in Objective c?

I am transferring a program from java to Objective C and need to use wait and notify methods that are frequently used for threading in java but can't seem to find any good equivalent in Objective C. I've tried using NSLock object but I don't think it is working. (I'm using [NSLock lock] for waits and [NSLock unlock] for notifies) Is there any good equivalent in Objective C that I haven开发者_如何学运维't been able to find?


There are numerous techniques you could use. You can use NSCondition or POSIX semaphores or dispatch semaphores or by using run loops. Check out the Concurrency Guide and the the Threading Guide.

My personal favourite at the moment is the dispatch semaphore.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜