这是说线程睡眠时必定抛出InterruptedException异常?
下面的代码为何不是输出true?
public class Test extends Thread{ public void run() { try { Thread.sleep(1000); System.out.println(Thread.interrupted()); Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } public static void main(String[] args) { new Test().start(); } }
习惯受伤
半枯
相关分类