R
Ryan Stewart
Reading a Java certification book, I came across this question:
"Which of these are plausible reasons why a thread might be alive, but still
not be running?
Select all valid answers.
a) The thread is waiting for some condition as a result of a call to wait().
b) The thread is waiting on a monitor for an object so that it may access a
certain member variable of that object.
c) The thread is not the highest priority thread and is currently not
granted CPU time.
d) The thread is sleeping as a result of a call to the sleep() method."
I said a, b, and d. The book says:
"a, b, c, and d
Note that only methods and code blocks can be specified as synchronized.
Variables cannot be declared as synchronized.Code blocks can be synchronized
on any object."
Their given reason seems to support my answer more than theirs. I'm thinking
typo. What do you think? What would your answer be?
"Which of these are plausible reasons why a thread might be alive, but still
not be running?
Select all valid answers.
a) The thread is waiting for some condition as a result of a call to wait().
b) The thread is waiting on a monitor for an object so that it may access a
certain member variable of that object.
c) The thread is not the highest priority thread and is currently not
granted CPU time.
d) The thread is sleeping as a result of a call to the sleep() method."
I said a, b, and d. The book says:
"a, b, c, and d
Note that only methods and code blocks can be specified as synchronized.
Variables cannot be declared as synchronized.Code blocks can be synchronized
on any object."
Their given reason seems to support my answer more than theirs. I'm thinking
typo. What do you think? What would your answer be?