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.
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.