diff b/w sleep(1000) and wait(1000)?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
Answer / satwant singhnagpal
In sleep method the thread does not release the object lock
| Is This Answer Correct ? | 3 Yes | 11 No |
Write program to print Hello World and print each character address in that string and print how many times each character is in that string? Ex: H: 0 & 1 e:1 & 1 l :2,3,8 & 3 o:4,6 & 2 w:5 & 1 r: 7 & 1 d 9 & 1
Does java arraylist maintain insertion order?
What is the use of predicate in java 8?
Can a class have a static inner class?
Can we sort list in java?
Explain about procedural programming language or structured programming language and its features?
What is flag in java?
How to sort array of 0 and 1 in java?
is there a separate stack for each thread in java? : Java thread
What is a return in java?
What is a variable in java?
placement papaers of spring computing technology
0 Answers Spring Computing Technologies,