A thread can have four states:
1, new, the thread has just been created, not executed
2, can be run (runnable), means that once the time shard mechanism has idle CPU cycles to a thread, that thread can start running immediately. Therefore, the thread may or may not be in operation, but once the condition permits, nothing can prevent it from running-it is neither "dead" nor "blocked".
3. Dead, after returning from its own run () method, a thread is "dead". You can also call Stop () to kill it, but create a violation-a subclass of error (that is, we don't usually capture it). Remember that a violation of the "throw" out should be a special event, not part of the normal program run. So it is not recommended that you use Stop () (in Java 1.2 is firmly opposed). There is also a destroy () method (which is never implemented) and should be avoided as much as possible because it is very arbitrary and does not unlock the object at all.
4, blocking (Blocked), the thread can run, but there is something blocking it. If the thread is in a blocked state, the scheduling mechanism can simply skip it and not allocate any CPU time to it. No action is taken unless the thread enters the "operational" state again. Why is it blocked because of:
(1) Call sleep (in milliseconds) to put the thread into a "sleep" state. This thread will not run for a specified period of time.
(2) The execution of the thread is paused with suspend (). The "operational" state is not returned unless the thread receives a resume () message.
(3) The execution of the thread is paused with wait (). The thread will not become "operational" unless it receives a nofify () or notifyall () message
(4) The thread is waiting for some IO (input and output) operations to complete.
(5) The thread attempts to invoke the "synchronous" method of another object, but that object is locked and temporarily unusable.
Four states of Java threads