Thursday, 3 September 2009

Java Certification Question 0084

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 or higher 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



Answer)


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 will depend on the threading algorithm of the Java Virtual Machine and the underlying operating system

No comments: