Question
A thread's run()
method has the following lines:
1. try {
2. sleep(100);
3. } catch (InterruptedException e) { }
Assuming the thread is not interrupted,
which one of the following statements is correct?
- A. The code will not compile, because exceptions cannot be caught in a thread's
run()
method. - B. At line 2, the thread will stop running. Execution will resume in, at most, 100 milliseconds.
- C. At line 2, the thread will stop running. It will resume running in exactly 100 milliseconds.
- D. At line 2, the thread will stop running. It will resume running some time after 100 milliseconds have elapsed.
D.
Note
The thread will sleep for 100 milliseconds, more or less.
Then the thread will enter the Ready state.
It will not actually run until the scheduler permits it to run.
PreviousNextRelated