这道关于线程的题,哪个叙述是正确的??急待,请逐个分析一下各个选项好吗?

wulingdongliu 2002-12-25 03:24:58
54. Which statement is true?

A. If only one thread is blocked in the wait method of an object, and another thread executes the notify on that same object, then the first thread immediately resumes execution.
B. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, it is still possible that the first thread might never resume execution.
C. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, then the first thread definitely resumes execution as a direct and sole consequence of the notify call.
D. If two threads are blocked in the wait method of one object, and another thread executes the notify method on the same object, then the first thread that executed the wait call first definitely resumes execution as a direct and sole consequence of the notify call.
...全文
137 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
study_body 2002-12-27
  • 打赏
  • 举报
回复
D,但是条件应该加上他们的优先级别上相同的基础上
jzld0627 2002-12-27
  • 打赏
  • 举报
回复
同意
选项 D If two threads are blocked in the wait method of one object
这样可以吗?
一个object 只有一个lock,一个线程wait取得了lock,另一个线程的wait()不会起作用吧?
wangdaoyong 2002-12-27
  • 打赏
  • 举报
回复
b吧,如果在另一个线程执行notify的时候,有更高优先级的其他线程(不需要这个notify)需要运行,则开始那个线程还是要等待

51,411

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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