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
State the merge-sort principle and its time complexity.
What is java and their uses?
What if constructor is protected in java?
Is hashmap thread safe?
Explain about anonymous inner classes in java?
Why does java have different data types for integers and floating-point values?
Does java set allow duplicates?
What is difference between static variable and global variable?
What is a null check?
What is map java?
What does sizeof return?
Why are arrays useful in java?
What is member in java?
Explain the difference between hashmap and hashtable in java?
Explain about class in java?