关于notify的问题
Given:
foo and bar are public references available to many other threads. foo
refers to a Thread and bar is an Object. The thread foo is currently
executing bar.wait(). From another thread, which statement is the
most reliable way to ensue that foo will stop executing wait()?
A. foo.notify();
B. bar.notify();
C. foo.notifyAll();
D. Thread.notify();
E. bar.notiFYAll();
F. Object.notify();
Answer: E
为什么呢?如果等待队列中的线程都已经被唤醒,这个时候调用notify()会不会有异常抛出?
static方法中是否不可以调用notify()和wait()方法?