java-based (multi-thread thread state --- and methods)

Thread Status:

5 states: newborn state, ready state, running state, blocking state, the state of death

 

 

Threading methods:

 sleep ()
   The thread to stop running for some time, will be in blocking state
   If you call after a sleep method, no other threads waiting to be executed, this time the current thread does not resume execution immediately!
 
 join ()
   Block the specified thread to wait until another thread to complete before proceeding.
 
 yield ()
   Let the currently executing thread is suspended, instead of blocking the thread, but the thread into the ready state;
   After calling the yield method, if no other thread is waiting to be executed, then the current thread will immediately resume execution!
 
 setDaemon()
   Specified thread can be set to a background thread, daemon thread;
   At the end of the thread to create a user thread a background thread also will perish;
   Before starting the thread can only set it to a background thread
 
 setPriority(int newPriority) getPriority()
   Priority thread is representative of the probability
   Ranges from 1 to 10, default 5
 
 stop () Stops thread
   Not recommended

Guess you like

Origin www.cnblogs.com/skyline1/p/11200600.html