Wait():
* Wait() method is an instance method of Object class.
* It will be in waiting state until notify() , notifyAll() called.
* Wait() will release the object lock.
* You should call the wait() method inside the synchronized block
Sleep():
* Sleep() method is a static method of Thread class.
* It will go to sleep until the specific amount of time.
* Sleep() will not release the object lock.
You can use Interrupt() method to Interrupt both wait() and sleep() state by throwing InterruptedException.
Please comment me if i am wrong.
No comments:
Post a Comment