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

Discussion

How a thread is asked to stop - which of the following is true?

  • A.Thread.destroy() ends a thread safely because it releases the thread's monitors first.
  • B.A thread ends as soon as its interrupt status is set, without needing to check it.
  • C.A thread cannot be forced to stop; the supported approach is a flag it checks and returns on.
  • D.Thread.stop() is the supported way to end a thread once it is no longer needed.

Answer: C

stop(), suspend(), resume() and destroy() are all deprecated. The javadoc recommends replacing them with code that sets a variable indicating the thread should stop, which the thread checks regularly before returning from run() in an orderly fashion. Ending a thread is always cooperative.

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

Post your comment

Please log in or register to post a comment.