Java線程中interrupted(),isInterrupted(),interrupt()區別。

  (1)interrupted()屬於Thread的靜態方法,第一次調用將會返回目標線程的中斷標誌,但是會將目標線程設置爲false狀態,第二次調用會返回false (2)interrupt()方法將線程中斷標誌設置爲true (3)isInterrupted()方法直接返回線程的中斷標誌,isInterrupted可多次調用而不會改變線程的中斷標誌 這個面試中常問到,可以記住    
相關文章
相關標籤/搜索