关于多线程的两道选择题

xiazdong 2013-08-15 10:44:30

求解下面两道题的详细分析,求大牛指导!

1. Which two CANNOT directly cause a thread to stop executing? (Choose Two)

A. Calling the yield method
B. Calling the wait method on an object
C. Calling the notify method on an object
D. Calling the NotifyAll method on an object
E. Calling the start method on another Thread object

Ans:A E

2. Which two CANNOT directly cause a thread to stop executing? (Choose Two)

A.Existing from a synchronized block
B.Calling the wait method on an object
C.Calling notify method on an object
D.Calling read method on an InputStream object
E.Calling the SetPriority method on a Thread object

Ans:A C


这两道题的答案很矛盾,第2题的C 就是第1题的C,但是一个是答案,一个不是答案。

题目中说的“CANNOT directly cause” 到底指的哪种:

(1)会导致线程停止运行,但是也可能不会导致。
(2) 无论怎么样也不会导致线程运行。

求指导!

...全文
183 2 打赏 收藏 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
H__coco 2013-08-16
  • 打赏
  • 举报
回复
CANNOT directly cause 的意思就是(1)的意思 但是你的第一题的答案应该错了,应该选C、D,只有这两个答案是肯定不会让线程停止的
valenon 2013-08-15
  • 打赏
  • 举报
回复
意思就是那两个不能直接导致线程停止执行。 当然,按照楼主很精确的理解划分,这里的不能导致应该指的是“不能保证一定会导致线程的执行”,所以我感觉应该是(1)的意思。 不过这个题仍然比较迷惑,个人感觉第一题除了B都符合条件。

62,620

社区成员

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

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