what is the difference between sleep() and Wait()?

Answer Posted / kumaran

thread.sleep(2000) - this will block the thread exactly 2000
milliseconds.

thread.wait(2000) - this will block the thread upto 2000
milliseconds.

i.e if thread.notify() calls before 2000 milliseconds, the
thread will become active incase if the thread is blocked by
wait().

Is This Answer Correct ?    14 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is procedure overloading?

1802


Can we declare main () method as non static?

524


What is the purpose of lambda expressions?

584


Can you use abstract and final both with a method?

573


What is meant by binding in rmi?

552






What is the Difference between Final Class && Abstract Class?

617


What is method in java ?

628


Does string is thread-safe in java?

593


What is supplier in java?

559


Which software is used for java programming?

559


what are Hostile Applets?

1606


What about interthread communication and how it takes place in java?

545


What is the difference between multitasking and multithreading in Java

723


Describe 2 different ways to concatenate two strings.

682


Can you make a constructor final in Java?

628