...
Compliant Solution (signalAll()
)
This compliant solution uses the {{ Wiki Markup signalAll()
}} method to notify all waiting threads. Before {{await()
}} returns, the current thread reacquires the lock associated with this condition. When the thread returns, it is guaranteed to hold this lock \[ [API 2006|AA. References#API 06]\]. The thread that is ready can perform its task while all the threads whose condition predicates are false resume ]. The thread that is ready can perform its task while all the threads whose condition predicates are false resume waiting.
Only the run()
method from the noncompliant code example is modified, as follows:
...
Bibliography
[API 2006] | | ||||
[JLS 2005] | |||||
Section 14.2.4, Notification | |||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="be92ae6b-a0a8-46f9-9771-c792325579a8"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. References#API 06]] | | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f1f54b6f-ac1f-45df-a38c-feea7fb7e61b"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. References#JLS 05]] | [Chapter 17, Threads and Locks | http://java.sun.com/docs/books/jls/third_edition/html/memory.html] | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5996727a-7cdd-4d19-b56d-c8eb83b76fe8"><ac:plain-text-body><![CDATA[ | [[Goetz 2006 | AA. References#Goetz 06]] | Section 14.2.4, Notification | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="03815210-0719-44c9-8916-4500e98bac22"><ac:plain-text-body><![CDATA[ | [[Bloch 2001 | AA. References#Bloch 01]] | Item 50. Never invoke wait outside a loop ]]></ac:plain-text-body></ac:structured-macro> |
...