在單個線程中使用NSNotifications時是否存在競態條件問題?下面是一個示例方法:NSNotification競爭條件
- (void) playerToggled: (NSNotification *) notification {
if (timerPane.playing && ! timerPane.paused) {
[playerPane toggleCurrentPlayer];
[timerPane toggleTimer];
[mainPane playerToggled];
}
}
的條件後的前兩個電話將觸發將由mainPane接收NSNotifications。 mainPane是否保證在收到通知後收到playerToggled消息?我應該說這個代碼似乎按照需要工作(playerToggled總是最後執行)。但我不確定在通知周圍存在什麼時間問題,我找不到具體的答案。
順便說一句,你應該真的接受你到目前爲止詢問的10個問題的一些答案。 –