JavaDoes the wait in it suspend the current thread or suspend the call to its thread?
wait()The method is a method in the Object class; when a thread executes to the wait () method, it enters a waiting pool associated with the object, while losing (releasing) the object’s machine lock (temporarily losing the machine lock, and waiting (long timeout) timeout time is requiredThe object lock should be returned; the synchronization method can be invoked and other threads can be accessed.
wait()Use notify or notifyAlll or specify sleep time to wake up threads in the current waiting pool.
wiat()You must put it in the synchronized block, or you will throw the “java. lang. IllegalMonitorStateException” exception when you program runtime.
waitA member method belonging to Object, once an object calls the wait method, must wake up the process with notify () and notifyAll () methods; if a thread has a synchronization lock for one or more objects, then after calling wait (), the thread willIt will release all the synchronous resources it holds, not limited to the object that is invoked by the wait () method. The wait () method can also be generated by calling the interrupt () method by other objects during the wait process.
wait()The role is to let
The current thread enters the wait state.，At the same time, wait () will also let.
The current thread releases the lock it holds.。“Until other threads call the notify () method or notifyAll () method of this object, the current thread is awakened (into “ready state”)
Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
The current thread must be the same as the thread calling it.