what is the difference between sleep() and Wait()?
Answer Posted / tisty
Simply speaking, we will use sleep() for pausing a thread
intentionally for some amount of time which we mentions in
milliseconds as the argument of sleep() method and,
wait() method is used whenever there is a communication is
needed between the threads, say if one thread's execution
is depended on the the execution of others.
The thread went on sleep will continue its execution after
the timeperiod. on the other hand, the thread undergone
wait will get activated on a notify() or notifyall() method.
Is This Answer Correct ? | 6 Yes | 2 No |
Post New Answer View All Answers
Can we sort set in java?
What is complexity and its types?
What is passing by reference in java?
Can variables be used in java without initialization?
How do I compare two strings in word in java?
What is nullpointerexception?
What are the differences between c++ and java?
Add a value x to array from index l to r where 0 <= l <= r <= n-1
What do you understand by the term polymorphism?
How do you change an int to a string?
What is tree in java?
What is the static keyword?
What are the two ways in which thread can be created?
How long will it take to learn java?
Define interface in java?