...
Ensure that a thread that holds locks on other objects releases them appropriately, before entering the wait state. Additional guidance on waiting and notification is available in guidelines THI03-J. Always invoke wait() and await() methods inside a loop and THI04-J. Notify all waiting threads instead of a single thread.
Noncompliant Code Example (Network I/O)
This noncompliant code example shows the method sendPage()
that sends a Page
object from a server to a client. The method is synchronized so that the pageBuff
array is accessed safely when multiple threads request concurrent access.
...