SCJP題庫第230題

 
Given that t1 is a reference to a live thread, which is true?
A. The Thread.sleep() method can take t1 as an argument.
B. The Object.notify() method can take t1 as an argument.
C. The Thread.yield() method can take t1 as an argument.
D. The Thread.setPriority() method can take t1 as an argument.
E. The Object.notify() method arbitrarily chooses which thread to notify.

Ans: E

解說:設t1是一個參考到存活執行緒的參考,何者為真?
答案E是說Object.notify()方法任意地選擇一個執行緒進行通知,這是對的,通知有二種,第一種是notify,第二種是notifyAll,二者的差異是notifyAll這種通知可以把所有在等待中的執行全數離開等待的狀態,而notify一次只能有一個等待中的執行緒離開等待的狀態。(有多個執行緒同時等待一個物件的情況下)

Comments

Popular posts from this blog

Android-使用webview在V3版的Google地圖GPS定位