Which statement is true?A. If only one thread is blocked in the wait method of an object, and another thread
executes the modify 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.
应该选什么,为什么
executes the modify 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.
应该选什么,为什么
B. 不会出现这种情况,不然Java这套机制岂不是有问题?
C. 正解
D. 不一定。如果有多个线程在waiting,notify哪一个是随机的。个人见解。请高手指正。