<%@ include file="../../ga4.jsp" %> Java Thread States [Synchronization] - Quiz Explanation

Thread States - Quiz Explanation

The answers you selected are indicated below, along with text that explains the correct answers.
 
1. The code
t.sleep(2000);
will
Please select the best answer.
  A. Put a thread to sleep for 2,000 seconds
  B. Put a thread to sleep for 2 seconds
  C. Not compile
  The correct answer is B. The code is correct. The sleep() method takes a value that specifies the number of milliseconds to sleep. The correct answer is that this puts the thread to sleep for 2,000 milliseconds, or 2 seconds.

2. If a thread's state becomes "not running" because its wait() method is invoked, which method needs to be invoked to test all waiting threads to see if they should wake up again?
Please select the best answer.
  A. wakeUp();
  B. notify();
  C. notifyAll();
  The correct answer is C. The method notifyAll() tests all threads to see if they should be awakened.

3. A thread will end its life when:
Please select the best answer.
  A. You invoke wait() for the thread
  B. You invoke sleep() for the thread
  C. The thread's run() method ends
  The correct answer is C. The wait() and sleep() method merely pause a thread. When the thread's run() method ends, the thread's life ends, as well.