基本上,问题标题怎么说。
Thread t = new Thread(someRunnable);
t.start();
t.interrupt();
t.join(); //does an InterruptedException get thrown immediately here?
从我自己的测试来看,但似乎只是想确定一下。我猜
Thread.join()
在执行其“等待”例程之前检查线程的interrupted
状态? 最佳答案
interrupt()
会中断您中断的线程,而不是正在中断的线程。
c.f.
Thread.currentThread().interrupt();
t.join(); // will throw InterruptedException