what is the difference between sleep() and Wait()?
Answer Posted / modi[achir communication pvt.
Wait() : This function takes parameters as milliseconds and
puts the thread in wait state for the desired time of the
programmer after time passes the execution starts again.
Sleep() : This function is also used for same purpose using
his function by java you can put a thread in sleep state
.sleep does not contains any parameters so the thread will
not be automatically start execution It needs a wake up
signal again which can be Notify().or other function are
also provided by java.
So the main difference in Wait() and sleep() is wait takes
time parameter and wait for specific time only and sleep
throws a thread in sleep mode for unspecified time.
| Is This Answer Correct ? | 6 Yes | 105 No |
Post New Answer View All Answers
when should you use stringbuilder class in a program?
If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?
Is stringwriter thread safe?
How many types of the indexof method are there for strings?
Which containers use a flowlayout as their default layout in java programming?
When the constructor of a class is invoked?
Explain access specifiers?
How many bits is a double?
what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread
What is the purpose of garbage collection in java?
What is passing by reference in java?
What is return type in java?
Define max and min heap, also the search time of heap.
What is meant by method?
Define interface in java?