ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

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

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.

 

Related Posts Plugin for WordPress, Blogger...
Flag Counter