This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Why is option 3 not a valid answer? The only valid answer given is 1. Under what circumstances might you use the yield method of the Thread class? 1) To call from the currently running thread to allow another thread of the same priority to run 2)To call on a waiting thread to allow it to run 3) To allow a thread of higher priority to run 4)To call from the currently running thread with a parameter designating which thread should be allowed to run Thanks in advance
According to the answer given on that page 1) To call from the currently running thread to allow another thread of the same or higher priority to run Option 3 looks plausible but there is no guarantee that the thread that grabs the cpu time will be of a higher priority. It willdepend on the threading algorithm of the Java Virtual Machine and the underlying operating system
If the thread which will be allocated CPU time is dependent on the threading algorithm of the JVM and the underlying operating system, then what is the guarantee that a thread of the SAME priority will run let alone a HIGHER priority? Then question 1 would have to be subject to review: (1)To call from the currently running thread to allow another thread of the same priority to run