Wednesday, November 30, 2011

Sleep() and Wait()

Difference between sleep() and wait() ?

1) wait() is a method of Object class. sleep() is a method of Thread class.
2) sleep() allows the thread to go to sleep state for x milliseconds. When a thread goes into sleep state it doesn’t release the lock. wait() allows thread to release the lock and goes to suspended state. The thread is only active when a notify() or notifAll() method is called for the same object

No comments:

Post a Comment