what is the difference between sleep() and Wait()?
Answer Posted / amitasite
Thread.sleep() is static method which make current running
thread "not runnable" for specific time. Sleeping thread
doesn't release lock. It will transit to "ready to run"
state after specified time elapsed or other thread interrupts.
wait() can be call on shared object. Wait can be call only
if thread has lock. On calling thread it releases lock on
object and transit to "not runnable" state. It wake ups and
transit to "ready to run" state after other thread that got
lock call notify() or notifyAll() on shared object or call
interrupt().
Is This Answer Correct ? | 11 Yes | 1 No |
Post New Answer View All Answers
What is the significance of listiterator?
What is super keyword explain with example?
What is fail first in java?
Is integer immutable in java?
Can we cast any other type to boolean type with type casting?
What is meant by overloading?
How do I compare two strings in word in java?
What means public static?
Can we override data members in java?
List some oops concepts in java?
What is the multi-catch block in java?
What is used of static keyword in java?
Is constructor inherited?
What do you mean by hashing?
What a static class can contains?