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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / gokul d

The thread which is under sleep state can be resumed back
automatically after the time mentioned.But thread under
wait has to be resumed back only by calling the notify()
method.

Is This Answer Correct ?    7 Yes 2 No

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

Answer / amod

the sleep() method is to make a thread to stop 4m working
for a fixed time sleep(5000)
it will make the thread to sleep for 5min
lly wait method ie wait()makes the thread to stop 4m
workin when other thread needs to excuteee

Amod s Dhupkar

Is This Answer Correct ?    9 Yes 4 No

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

Answer / satwant singhnagpal

In sleep method the thread does not release the object lock

Is This Answer Correct ?    3 Yes 11 No

Post New Answer

More Core Java Interview Questions

How will you add panel to a frame?

0 Answers  


How many types of the indexof method are there for strings?

0 Answers  


How to create two different thread class inside a main function?

1 Answers  


What are the wrapped, classes?

0 Answers  


Is java still relevant?

0 Answers  






Why local variables are stored in stack?

0 Answers  


There can be a abstract class without abstract methods, but what is the need to declare a class abstract if it doesn't contain abstract methods?

5 Answers   HCL,


There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it?

9 Answers   KPIT,


If an object reference is set to null, will the garbage collector immediately free the memory held by that object?

0 Answers  


What is multi-catch block in java?

0 Answers  


What are thread priorities and importance of thread priorities in java?

0 Answers  


how can you take care of mutual exclusion using java threads? : Java thread

0 Answers  


Categories