我正在为iPhone编写并发应用程序。 我不知道如果这个代码:在循环中阻塞相当于空的互斥锁?
while(!conditionBoolean)
{
// do nothing
// until another thread makes this variable true.
}
makeWork();
等同于以下内容:
[lock lock]; // this lock is locked by another thread
// causing the current to block until it's unlocked
[lock unlock];
makeWork();
如果不是,有什么区别?
谢谢。
谢谢史蒂夫!你能给出一个信令原语的例子吗? – wh1t3cat1k 2010-12-08 16:46:05
例如。 `NSConditionLock` - 请参阅http://objc.toodarkpark.net/Foundation/Classes/NSConditionLock.html – 2010-12-08 16:50:03