Which of the following is true?
a. The Thread.yield method might cause the thread to move to the blocking state.
b. The Thread.yield method might cause the thread to move to the ready state.
c. The same thread might continue to run after calling the Thread.yield method.
d. The Thread.yield method is a native method.
e. The behavior of the Thread.yield method is consistent from one platform to the next.
f. The Thread.sleep method causes the thread to move to the blocking state.
g. The Thread.sleep method causes the thread to move to the ready state.
h. None of the above.
The thread.yield method is intended to cause the currently executing thread to move from the running state to the ready state and offer the thread scheduler an opportunity to allow a different thread to execute based on the discretion of the thread scheduler. The thread scheduler may select the same thread to run immediately or it may allow a different thread to run. The thread.yield method is a native method so the behavior is not guaranteed to be the same on every platform.
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Originally posted by Barry Gaunt:
Dan, referring to the question above, the API says that Thread.yield() is public static void. There is no mention of it being native, and I wouldn't expect a question requiring knowledge of that fact to turn up in the exam.
-Barry
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
It's just a flesh wound! Or a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
|