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

How do you use wildcards?

528


Is void a keyword in java?

590


What are reference variables in java?

592


Explain about doubly linked list

614


What is an example of declaration?

519






Explain aggregation in java?

543


What is lexicographically smallest string?

596


What are the data types supported by java?

544


What is JVM and is it platform independent?

558


What is bean? Where it can be used?

595


Is 0 true or false in java?

515


What is internal iteration in java se 8?

625


What is anagram word?

519


What are the advantages and disadvantages of reference counting in garbage collection?

573


What happens if we override private method?

521