diff b/w sleep(1000) and wait(1000)?

Answer Posted / rajani nagandla

The sleep method is used when the thread has to be put
aside for a fixed amount of time. Ex: sleep(1000), puts the
thread aside for exactly one second. The wait method is
used to put the thread aside for up to the specified time.
It could wait for much lesser time if it receives a notify
() or notifyAll() call. Ex: wait(1000), causes a wait of up
to one second. The method wait() is defined in the Object
and the method sleep() is defined in the class Thread.

Is This Answer Correct ?    44 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of System class?

624


Detail discussions on JVM, memory management and garbage collector.

562


How will you get the platform dependent values like line separator, path separator, etc., ?

593


How many inner classes can a class have?

591


What is a predicate method?

570






Difference between static and dynamic class loading.

602


what do you understand by synchronization? Or what is synchronization and why is it important? Or describe synchronization in respect to multithreading? Or what is synchronization? : Java thread

498


What do you understand by abstract classes?

614


What happens when a thrown exception is not handled?

590


What causes memory leaks in java?

500


why are wait(), notify() and notifyall() methods defined in the object class? : Java thread

560


Explain about the interpreter in java?

638


Compare Mutex and Semaphore in java.

566


Can we define package statement after import statement in java?

569


What is lexicographically smallest string?

607