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

Differentiate between array list and vector in java.

736


Why string objects are immutable in java?

668


Why do we need wrapper class?

631


There are two classes named classa and classb. Both classes are in the same package. Can a private member of classa can be accessed by an object of classb?

1104


Can we create a class inside a class in java?

633






What are the basic interfaces of java collections framework?

704


Define "Access specifiers" in java.

755


What are the important features of Java 8 release?

669


What does a za z0 9 mean?

641


Is there any tag in htm to upload and download files?

695


Can java run on google chrome?

698


How do I convert a string to an int in java?

651


How to check if linked list contains loop in java?

544


How objects are stored in java?

633


How many bits is a float?

644