Notify,NotifyAll and Wait in Java Programming
Previous | Home | Next |
notify(),notifyAll() and wait() methods are defined into Object class as public final with void return type.
. notify() method define into Object class as public final with void return type .This method is used in thread .This methods tell a single thread wakes up which is in waiting state. notify() method should only be called by a thread that is the owner of this object's monitor. notify() method may throws IllegalMonitorStateException - if the current thread is not the owner of this object's monitor. notifyAll() methods define as public final with void return type into Object class of java. notifyAll() method is used to wakes up all threads that are waiting on this object's monitor.It may throws IllegalMonitorStateException - if the current thread is not the owner of this object's monitor. wait(long timeout) is define as public final void into Object class. It throws InterruptedException exception if timeout <0 or any other thread interrupt or current thread is not owner of the object’s monitor. IllegalArgumentException - if timeout<0. IllegalMonitorStateException - if the thread is not the owner of the object's monitor. InterruptedException - if another thread is interrupte the current thread public final void wait(long timeout, int nanos) Wait until another thread invokes the notify() method or the notifyAll() method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed. The method is similar to the wait method of one argument. public final void wait() throws InterruptedException Wait until another thread invokes the notify() method or the notifyAll() method for this object.
Previous | Home | Next |