![](/img/trans.png)
[英]Java: thread able to call a method that is in synchronised block of some other thread
[英]Can some subclass from Thread call Condition's function signal() if any other Thread isn't call await()?
例如,兩個線程(Informer 和 Watcher)使用相同的 List。 Informer 在 List 中添加數據,如果集合為空或者 Informer 訪問 List,則 Watcher 無法讀取集合。 如果 Informer 調用函數 Condition.signal() 但 Watcher 未創建或未啟動(Watcher not call Condition.await() )會發生什么?
是的,即使沒有等待線程,也可以調用signal
。 等待線程將錯過此信號,並且在調用await()
時會被阻塞。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.