wait, notify and notifyAll method in java with example
GIAN Tutorials
7:55 AM
You might have noticed Object class has three final method called wait, notify and notifyAll. These methods are used for inter thread communication. Java 5 has introduced executor framework which takes care of inter thread communication for you and internally uses wait, notify and notifyAll but you still require basic understanding of these methods and how inter thread communication works in java using wait , notify and notifyAll. What are wait , notify and notifyAll methods? wait , notify and notifyAll method are used to allow threads to communicate to each other via accessing common object or in other terms, Object can be considered a medium for inter thread communication via these methods. These methods need to be called from synchronized context,otherwise it will throw java.lang.IllegalMonitorStateException. Some background on synchronized block : Only one thread can enter at a time in synchronized block A thread required lock on the object ...