Java threads in the life cycle can be divided into five states.

http://www.manongjc.com/java_example/thread_status.html

  • 1. Create a new state (New): create a new thread object.
  • 2. ready state (Runnable): After the thread object is created, other thread calls the start () method of the object. The state of the thread runnable threads in the pool is located, has become runnable, waiting to acquire the right to use the CPU.
  • 3. Run state (Running): ready state of the thread gets the CPU, executes the program code.
  • 4. blocked (Blocked): the thread is blocked for some reason to give up the right to use CPU temporarily stops running. Until the thread into the ready state, a chance to go running. Case of obstruction of three categories:
    • (A), waiting for blocking: execution wait thread run () method, JVM will thread into the wait pool.
    • (Two), synchronous blocking: threads running at the time of acquiring synchronization lock object, if the synchronization lock is occupied by another thread, the JVM will lock into the thread pool.
    • (C) Other blocking: a thread of execution sleep () or join () method, or issue the I / O request, the JVM will set the thread is blocked. When sleep () timeout, the Join () or a timeout wait for a thread to terminate, or I / O processing is completed, the thread into the ready state again.
  • 5. death state (Dead): thread execution is over or due to abnormal exit the run () method, the thread end of the life cycle.

Guess you like

Origin www.cnblogs.com/Andrew520/p/12097577.html