Originally posted by ramya narayanan:
sleep(1000)-->cannot be interrupted
Are you sure? Then why can it throw an InterruptedException?
wait, unlike sleep, triest to acquire a lock on the object. wait() will wait indefinitely until the lock can be acquired (or until the call is interrupted), wait(long) and wait(long, long) will do the same but after the specified time has been reached it will no longer block. All three
must be called in a block or method that synchronizes on the object on which wait is called.
sleep just puts the thread to sleep without any locking.