publicvoidrun(){ while(!isInterrupted()){ try{ Thread.sleep(3000); }catch(Exception e){ e.printStackTrace(); break; } } } } 注意:使用interrupted()方法來中斷線程有兩種情況: 3.1.1 線程處于阻塞狀態(tài),如線程中使用了sleep(),同步鎖 wait(),socket的receiver,accept方法時,會使線程進入到阻塞狀態(tài),...
www.dbjr.com.cn/article/1822...htm 2025-5-31