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
Why hashmap is used in java?
Can we store variables in local blocks?
Does sprintf allocate memory?
Why singleton class is used in java?
Why string is called as immutable?
Why is java called the platform independent programming language?
What isan abstract class and when do you use it?
Explain about anonymous inner classes ?
What is Java Reflection API? Why it’s so important to have?
What is method overloading in JAVA? Why is it not present in C ?
What is the difference in between cpp and java? Can u explain in detail?
How do you remove all elements from an arraylist in java?
What will happen to the exception object after exception handling?
What about instanceof operator in java?
How is a variable stored in memory?