SCJP題庫第220題
Which factor or factors
A. It is possible for more than two threads to deadlock at once.
B. The JVM implementation guarantees that multiple threads cannot enter into a deadlocked state.
C. Deadlocked threads release once their sleep() method's sleep duration has expired.
D. Deadlocking can occur only when the wait(), notify() and notifyAll() methods are used incorrectly.
E. It is possible for a single-threaded application to deadlock if synchronized blocks are used incorrectly.
F. If a piece of code is capable of deadlocking, you cannot eliminate the possibility of deadlocking by inserting invocations of Thread.yield().
Ans: AF
解說:
A 有可能2個以上的執行進入死結狀態 是的
B JVM實作保證執行緒不會進入deadlock à 死結避免是程式設計師要做的事,不是環境要做的事
F 若部份的程式碼有產生死結的可能,你無法藉由插入Thread.yield()呼叫而消除死結的可能性。à 死結要避免必須程式本身要進行資源配置計劃,而不是藉由插入一個退讓(yield)敘述就可以避免的。
Comments