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
For class CFoo { }; what default methods will the compiler generate for you>?
What is a short in java?
What is jvm? How its run?
Can subclass overriding method declare an exception if parent class method doesn't throw an exception?
What is covariant return type?
What is the concatenation operator in java?
Define linked list and its features with signature?
what is enumset?
What is object in java?
If you are given the name of the function at run time how will you invoke the function?
Explain java coding standards for classes or java coding conventions for classes?
Is treeset sorted in java?
Explain what are final variable in java?
What is java thread dump, how can we get java thread dump of a program?
What's the access scope of protected access specifier?