Question: What's the difference between the methods sleep() and wait()
Answer: The code sleep(1000); puts thread aside for exactly one second. The code wait(1000), causes a wait of up to one second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.
Is that right? A sleep thread can be interrupted by another thread too. I'm a little confused about: sleep/interrupt vs. wait/notify
Another important difference is that wait gives up the monitor on the object (which is in fact why you need to call it on an object).
The uses are totally different. You will use sleep when you just want the current thread to sleep for some time. You use wait when you want the thread to wait for an event in another thread, that is signaled via notify/notifyAll.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
subject: What's the difference between the methods sleep() and wait()