246 results

Show search filters
Calling wait, notify, and notifyAll within a non-synchronized method

Calling wait, notify, and notifyAll within a non-synchronized method

You may be used to seeing the wait(), notify(), and notifyAll() methods called within synchronized methods. But here's a subtlety that you may not know: The caller of the wait(), notify(), and notifyAll() methods is required to own the monitor for which it's invoking these methods. This point sometimes goes unnoticed because programmers are used to calling these methods from within synchronized methods.

May 5, 2005 by