The method to get the current thread object is: Thread.CurrentThread ();
When the thread target's Run method ends, it means that the thread finishes
The state of the thread:
1) New state: Thread object has been created, but the Start method has not been called
2) Operational Status: The Start method is called. or after running, from blocking to waiting for sleep after returning.
3) Operation Status: Start running, can see a buffer of the running state when the field can run
4) Wait for sleep blocking state: Frozen state
5) Death, Run method end
To prevent a thread from running:
Sleep: Thread.Sleep ()
The priority of the thread and the concession of the thread:
SetPriority () thread priority between 1~10, default is 5
Thread.yield () is likely to have no effect. Because the concession thread will still be checked by thread scheduling again.
To join a thread:
Join ()
The non-static method of thread join () lets a thread B "join" to the tail of another thread A. b does not work until a is complete.
The join () method also has an overloaded version with a time-out limit. For example, T.join (5000); Let the thread wait 5000 milliseconds, if it exceeds this time, then stop waiting, become operational state
Since synchronization and lock look a little more complicated, the next time specifically to watch.
This article from "ehealth" blog, declined reprint!
Java Learning notes----Thread 2