1
当一个线程t
调用对象u
在wait()
方法,它进入等待状态,直到另一个线程对同一对象u
OR另一个线程调用interrupt()
方法上调用notify()
等待线程t
。考虑到等待的线程不消耗CPU周期,等待线程如何检查wait()
中的中断状态并抛出InterruptedException
?检查从等待中的中断状态()
也就是说,我想下面的代码中wait()
:
if (Thread.interrupted()) // Clears interrupted status!
throw new InterruptedException();
太棒了,我现在画一幅画。非常感谢。 –