Machine-translated by Google. Questions are authored in English.
Top

Discussion

The Thread.State enum - which of the following is true?

  • A.Thread.State has four values: NEW, RUNNING, WAITING and DEAD.
  • B.Thread.State has six values, with SLEEPING in place of TIMED_WAITING.
  • C.Thread.State has six values: NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING and TERMINATED.
  • D.Thread.State has five values, with RUNNING used in place of RUNNABLE for a thread on a processor.

Answer: C

Those six are the whole enum. There is deliberately no RUNNING state: a thread that is executing and one merely eligible to execute are both RUNNABLE, because the JVM does not distinguish them. A sleeping thread reports TIMED_WAITING, and getState is documented for monitoring rather than for control.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.