Wait and notify are for sychronized locked objects.
Sychronized (object) object.wait ();//Release the lock of object
Sychronized (object) object.notify ();//will randomly evoke a waiting thread on the object yoke, the process is randomly awakened, unfair
Sychronized (object) Object.notifyall ()//will wake up all threads that lock on object
Suspend (thread hang) and resume (continue)
Suspend the lock is not released after the thread is suspended until the resume operation;
If the resume is executed before suspend, then the thread is hard to wake up, and the thread or runable from the threading point of view will always affect the system.
If optimization suspend need to be implemented with wait and notify
Join and yield
Join means waiting for thread to end execution again
Yield indicates humility, which means that the current thread gives up the CPU and lets other threads work.
Addthread at=new Addthrea ();
At.start ();
At.join ();
Indicates that the current thread is blocked, waiting for the at thread to complete before executing the current thread
Join (Millis) means that if it is not executed after waiting for Millis, it will go directly to execute
Java Multithreading Basics