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 stored procedure. How do you create stored procedure ?
How many types of constructors are used in java?
Can a source file contain more than one class declaration?
What is the integer of 16?
Write a program to reverse a number in java?
How finally used under exception handling?
Explain the importance of join() method in thread class?
What is variable length arguments in java?
Why arraylist is used in java?
What is a lock or purpose of locks in java?
What are constants?
What is sortedmap in java?
Can list contain null in java?
How does varargs work in java?
Which are the two subclasses under exception class?