Wait
Wait for the Operation to occur after the wait () or time form wait (long millisecs) and wait (long millisecs, int nanosecs) are called. A wait (long millisecs) call with parameter 0 or a call with two 0 parameters of wait (long millisecs, int nanosecs) is equivalent to a call with wait.
If the thread does not return interruptedexception when an interrupt exception is thrown, the thread returns normally from wait.
Notification
The notification operation occurs after calling notify () or notifyall. Make thread t any thread that executes the method on object m, and make n the number of lock operations on object m by thread t, and N is not matched by the unlock operation, the following situations may occur:
- If n = 0, illegalmonitorstateexception is thrown. The scenario is: thread t has no lock occupying the target object m;
- If n> 0, and this is a notify () operation, if the object mWaitIf the set is not empty, the object m is waiting for a member thread U in the set to be selected and deleted from the waiting set, so that the thread u can continue in the waiting operation. Note that the U Lock operation can be successful only after T completely unlocks the object m monitor;
- If n> 0, and this is a policyall () operation, then all waiting threads wait for the collection to be deleted.
Interrupted
An interrupted operation occurs after the call method thread. Interrupt () or new threadgroup (). Interrupt.
Interaction of waiting, notification, and interruption