关于notify的问题

bis_dll 2008-07-31 09:34:56
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()方法?
...全文
87 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧