1. 程式人生 > >Java執行緒生命週期圖

Java執行緒生命週期圖

在這裡插入圖片描述

  1. synchronized(waiting to enter monitor)等待獲得鎖
  2. synchronized(enter monitor)獲得鎖
  3. wait( )
    join( )
    LockSupport.park( )
  4. notyfy( )、notifyAll( )、interrupt( )且獲得鎖
    子執行緒結束(對應join( ))
    LockSupport.unpark( )
  5. Thread.sleep(millis)
    wait(long)
    join(long)
    LockSupport.parkNanos(nanos)
    LockSupport.parkUntil(deadline)
  6. Time Waiting結束
    notify( )、notifyAll( )
    子執行緒結束(對應join( ))
    LockSupport.unpark( )
    interrupt( )且獲得鎖
  7. Time Waiting結束
    notify( )、notifyAll( )
    interrupt( )且等待獲得鎖
  8. notify( )、notifyAll( )
    interrupt( )且等待獲得鎖

Java執行緒狀態分析/執行緒狀態轉換圖參考:https://blog.csdn.net/shi2huang/article/details/80289155