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 does replaceall do in java?
How do you read and print a string in java?
Name some classes present in java.util.regex package.
How do you declare an array that will hold more than 64KB of data?
What's the default access specifier for variables and methods of a class?
Explain about procedural programming language or structured programming language and its features?
How to make a non daemon thread as daemon?
Explain about public and private access specifiers?
Explain wait() method of object class ?
What is a lightweight component?
Who is founder of java?
What is the difference between logical data independence and physical data independence?
Can java arraylist hold different types?
How are the elements of a gridbaglayout organized in java programming?
What are the types of collections in java?