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
What is thread pool in java with example?
What is length in java?
What is hashtable and explain features of hashtable?
What is void data type?
How many bits is a string in java?
How is it possible for two string objects with identical values not to be equal under the == operator?
Difference between nested and inner classes ?
Define reflection.
Explain numeric promotion?
how can you take care of mutual exclusion using java threads? : Java thread
What is a map? What are the implementations of map?
What are the concepts of 'OOPS'?
What is encapsulation in java?
Can we define static methods inside interface?
What is the covariant return type?