Wait ()/notify ()/notifyall () in the 1.Object class
Wait (): leave the current thread in the waiting state and release the held object lock until another thread calls this object's thread notify ()/notifyall () method, and the current thread is awakened into the runnable state.
Wait (long timeout): leave the current thread in the timed waiting state and release the held object lock until another thread calls this object's thread notify ()/notifyall () method or time expires. The current thread is awakened into the runnable state.
Wait (long timeout, int nanos): leave the current thread in the Timed waiting state, until other threads call the Notify () method of this object or the Notifyall () method, or some other thread interrupts the current thread, or the time expires, the current thread is awakened into the runnable state.
notify (): randomly wakes a single thread waiting on this object monitor (does not immediately release the held object lock until the synchronized method or syntax block finishes executing to actually release the lock).
notifyall (): randomly wakes all the threads that are waiting on this object monitor (does not immediately release the held object lock until the synchronized method or syntax block finishes executing to actually release the lock).
Sleep ()/yield ()/join () in the 2.Thread class
sleep (): lets the current thread pause for a specified time (in milliseconds), the sleep method only temporarily yields the CPU's execution, and does not release the lock in the synchronized-modified synchronization method or code block.
yield (): suspends the current thread so that other threads have an opportunity to execute, but cannot specify a time to pause, and there is no guarantee that the current thread will stop immediately and give up the CPU's execution temporarily.
join (): let the current parent thread wait for the child thread to execute before executing, but one thing to note is that the join here only calls the Wait method, but there is no corresponding notify method, because the thread's Start method does the corresponding processing, So when the join thread finishes executing, the main thread is automatically awakened to continue execution.
Java Multithreaded Series Foundation article Wait/notify/sleep/yield/join