0
Difference between wait and sleep in Java?
Difference between wait and sleep in Java?
2 odpowiedzi
+ 2
As far as I know, wait is to wait for a certain task to be completed and the sleep is simply to stand in wait for a while. (Translation direct of words is right).
0
wait call only returns when either it was notified or on spurious wakeups. On the other hand sleep call returns when the interval as finished or also on spurious wakeups.
Don't forget that both can throw InterruptedException wheneaver the thread is interrupted.