線程的狀態轉移


當一個ThreadState剛剛被創建的時候,它的Threadstate是unstarted。
調用Start()之後,它的Threadstate變成Running
如果想讓它阻塞,調用sleep()方法,threadstate變成waitesleepjoin
此外這個線程如果調用了其他對象的wait或者join也會使自身的threadstate變成waitsleepjoin
處於waitesleepjoin的狀態如果想喚醒它,可使用interrupt方法,將在線程中引發threadinterruptedexception異常,進入中斷處理模式,threadstate變成running
另外一個線程調用此線程的abort,那麼此線程的threadstate變成AbortRequested
線程響應 Abort 請求。threadstate變成stop
線程停止threadstate爲stop
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章