Page 1 of 1

About Question com.enthuware.ets.scjp.v6.2.79 :

Posted: Wed Nov 23, 2011 12:05 pm
by shkolnik
The question is: "Identify the code that can potentially move a thread from one state to another"

Under the arrow from Running --> Runnable, I have put "No code required", because JVM can at any time decide to move the thread from Running to Runnable without any code hints.

This answer has be marked as wrong.

Re: About Question com.enthuware.ets.scjp.v6.2.79 :

Posted: Fri Nov 25, 2011 8:27 am
by stessy
The important keyword in that question is "Potentially".

The yeld() can potentially move the current running Thread to the Runnable pool. But it's not guaranteed.

Re: About Question com.enthuware.ets.scjp.v6.2.79 :

Posted: Fri Nov 25, 2011 10:22 am
by shkolnik
I am not disputing that Thread.yield() is a correct answer. My point is that "no code required" is also correct. Wouldn't you agree that following is true?

"No code is required to potentially move a thread from running to runnable"

The test should be modified to accept "no code is required" as a correct answer.

Re: About Question com.enthuware.ets.scjp.v6.2.79 :

Posted: Sun Nov 27, 2011 4:33 am
by stessy
Normally, both should be accepted. Thread.yield() or the scheduler (No action required).

Re: About Question com.enthuware.ets.scjp.v6.2.79 :

Posted: Sun Nov 27, 2011 8:22 pm
by admin
You are right. It should accept "No code required" as well. This has now been fixed.

thank you for your feedback!