Which three statements are correct about thread’s sleep method?
A.
The sleep (long) method parameter defines a delay in milliseconds.
B.
The sloop (long) method parameter defines a delay in microseconds.
C.
A thread is guaranteed to continue execution after the exact amount of time defined in the sleep
(long)parameter.
D.
A thread can continue execution before the amount of time defined in the sleep (long)
parameter.
E.
A thread can continue execution after the amount of time defined in the sleep (long) parameter
F.
Only runtime exceptions are thrown by the sleep method.
G.
A thread loses all object monitors (lock flags) when calling the sleep method.
Explanation:
sleep (long millis) not B
Causes the currently executing thread to sleep (temporarily cease execution) for the specified
number ofmilliseconds(A, not B)
millis – the length of time to sleep in milliseconds.
throws InterruptedException: – if another thread has interrupted the current thread. The interrupted
status ofthe current thread is cleared when this exception is thrown.
java.lang.Throwable
java.lang.Exception
java.lang.InterruptedExceptionThe thread does not lose ownership of any monitors. It means that if the thread has an objectmonitor, all otherthreads that need that monitor are blocked.
This method can be called regardless whether the thread has any monitor or not.
The answer should be A D E.
C is wrong – no gurantee to continue after the “exact” amount of time.
+1
+1
A D E are correct
The comments are right; ADE should be the answer.