Sunday, 17 April 2011

What is the difference between wait() and sleep()?

1) wait() is a method of Object class. sleep() is a method of Object 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