当前位置: 技术问答>java相关
选什么.为什么2
来源: 互联网 发布时间:2015-01-24
本文导语: Which of the following statements is/are true? Choose all correct options. A) At the moment a thread calls an object's wait() method, the thread must own that object's lock. B) At the moment a thread calls an object's wait() method, the threa...
Which of the following statements is/are true? Choose all correct options.
A) At the moment a thread calls an object's wait() method, the thread must own that object's lock.
B) At the moment a thread calls an object's wait() method, the thread loses that object's lock.
C) At the moment a waiting thread is notified, it is given the lock of the object for which it was
waiting.
D) At any moment, a thread may not be waiting for the lock of more than one object
选什么.为什么
A) At the moment a thread calls an object's wait() method, the thread must own that object's lock.
B) At the moment a thread calls an object's wait() method, the thread loses that object's lock.
C) At the moment a waiting thread is notified, it is given the lock of the object for which it was
waiting.
D) At any moment, a thread may not be waiting for the lock of more than one object
选什么.为什么
|
A,D
A,B冲突
C.At the moment a waiting thread is notified,
状态变化:waiting->seeking lock->ready->running
A,B冲突
C.At the moment a waiting thread is notified,
状态变化:waiting->seeking lock->ready->running
|
看清楚,A,B并没有冲突,他们指的时间是不一样的。
wait之间是要得到object lock,wait了object lock就给出去了。
wait之间是要得到object lock,wait了object lock就给出去了。
|
没有疑问 a,d,panq说的不错。
a对:不用说了吧。
b错。
c:一个lock被释放,在等待这个lock的线程都会被notify.谁能拿到lock,看系统调度,一般看优先级。
d:等待lock就阻塞了,这是串行的,不会同时等待其他object的lock。
a对:不用说了吧。
b错。
c:一个lock被释放,在等待这个lock的线程都会被notify.谁能拿到lock,看系统调度,一般看优先级。
d:等待lock就阻塞了,这是串行的,不会同时等待其他object的lock。
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。