What statements are true concerning the method notify() that is used in conjunction with wait()?
Select all valid answers.
a) if there is more than one thread waiting on a condition, only the thread that has been waiting the longest is notified
b) if there is more than one thread waiting on a condition,there is no way to predict which thread will be notifed
c) notify() is defined in the Thread class
d) it is not strictly necessary to own the lock for the object you invoke notify() for
e) notify() should only be invoked from within a while loop
这个应该是scjp的题目。大家看看应该选哪个,我英文还不打过关啊。
Select all valid answers.
a) if there is more than one thread waiting on a condition, only the thread that has been waiting the longest is notified
b) if there is more than one thread waiting on a condition,there is no way to predict which thread will be notifed
c) notify() is defined in the Thread class
d) it is not strictly necessary to own the lock for the object you invoke notify() for
e) notify() should only be invoked from within a while loop
这个应该是scjp的题目。大家看看应该选哪个,我英文还不打过关啊。
解决方案 »
- 哪位朋友能帮我解析一下这个关于求最大子序列的算法了?
- 谁能发一点SCJP 5.0 的模拟考试题目
- 2种Main函数写法的区别
- 把数字写到文件中出错
- 50分Repaint方法调用的问题!
- 难题一个,关于applet的,有兴趣的进! 18-JAN-2007 21:00 结帖
- Hashtable如何转换成或序列化成字符串
- JB2006使用JDK6以及JDK5-->JDK6的暴力编译(原创一个)
- 请教输出问题,谢谢!
- 我想在每个月第一天的0:00点做一件事情
- Java算不对 1.2×1.5!!!
- 求教:java.awt.Component的getSize()等类似方法 在何时取用才可以得到Component的实际大小???
1那些关于notify()和wait()方法联合使用的描述是正确的?
a)如果有多个等待该锁的线程,只有那个等待时间最长的线程被通知。(错误,是任意选出一个通知的)
b)如果有多个等待该锁的线程,没有方法知道那个线程将被通知。
c)notify() 定义在Thread 类中。(notify定义在Object中)
d)当调用notify()不是必须获得该对象的锁。(错误,必须获得锁)
e)notify()仅应该在循环中调用。(错误)