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


Please Help Members By Posting Answers For Below Questions

Explain about fail fast iterators in java?

564


Can we initialize the final blank variable?

584


When does an object becomes eligible for garbage collection in java?

580


What will happen if a thrown exception is not handled?

564


What happens if I remove static from main method?

526






Is minecraft java edition free?

578


How many java versions are there?

562


How do you reverse sort a list in java?

514


What is :: operator in java?

511


What is difference between local variable and global variable?

474


What is the purpose class.forname method?

560


What is pass by value?

512


Why collection doesn’t extend cloneable and serializable interfaces?

644


What is structure of java heap? What is perm gen space in heap?

544


What is the biggest integer?

554