java questions

java questions

what is the difference between wait() and sleep() methods in thread class?

View Answers

January 12, 2011 at 4:21 PM

Hi Friend,

1) wait()is a Object class method whereas sleep() is a thread class method.

2)The sleep method sends the current thread into Non-Runnable state for the specified amount of time but it doesn't cause the thread to loose ownership of the acquired monitors.The wait() method also sends the current thread into Non-Runnable state like the sleep() method but wait() method, the locks are released before going into Non-Runnable state, so that any other thread that is waiting on the object can use it.

3)Sleep method will not release the lock after completion of time but wait method does.

For more information, visit the following links:

Wait Method

Sleep Method

Thanks

Thanks

Ads









Related Tutorials/Questions & Answers:
java questions
java questions  why java is not open source
java questions
java questions  why java is not open source
Advertisements
java questions
java questions  can i write an inner class in an interface
java questions
java questions  what is the proper way of code our program?   Have a look at the following link: Core Java Tutorials
Java Questions
Java Questions   How to dispaly my databsae records in my jsp page using collections My java class   Visit Here
Java Questions
Java Questions   How to dispaly my databsae records in my jsp page using collections My java class   Visit Here
java questions
java questions  what is the difference between wait() and sleep() methods in thread class
java questions
java questions  how is java platform independent? is jsp thread safe... (known as the Platform independent) is one of the important key feature of java language that makes java as the most powerful language. When Java Code
java Questions
java Questions  do we need to implement all methods interface if yes I want example code please send me
Java Interview Questions
Java Interview Questions  Hi, Can anyone tell the urls of Java Interview Questions on roseindia.net? Thanks
Questions about Java's String pool
Questions about Java's String pool  Questions about Java's String pool
Interview Questions - What is Java?
Interview Questions - What is Java?  What is Java?   Hi, Java is high level programming langue developed by James Gosling. Now Java.... Check in detail at: What is Java? View all Java Interview Questions
Java Questions & Java FAQ
Java Questions & Java FAQ  ... have listed the Java Questions which are commonly asked. Our collection... questions about the Sun Programming Language.  Here are the list of those Java
Java interview questions and answers
Java interview questions and answers   what is garbage collection? What is the process that is responsible for doing that in java? Ans.Reclaiming... in Java? Ans. Runtime.getRuntime().exec(?.) 5.What is the basic difference
Interview Questions - Where Java is used?
Interview Questions - Where Java is used?  Hello, Where Java is used? Thanks   Hi, Java is used for creating various types... being Used?. View all interview questions at Java Interview Questions with Answers
Java interview questions
Java interview questions  Plz answer the following questions..... The type long can be used to store values in the following range: a. -263 to 263 - 1 b. -231 to 231 - 1 c. -264 to 264 d. -232 to 232 - 1 Which
Interview Questions - How Java is Used?
Interview Questions - How Java is Used?  Hi, How Java is Used... For Creating Applets Check: Where is Java being Used? View all interview questions at Java Interview Questions with Answers page. Thanks
Java - Java Interview Questions
Java  definition for "USER DEFINE PACKAGE FOR JAVA
Java - Java Interview Questions
Java  What is meant by Stream Tokenizer ?   hi friend, To understand the Stream Tokenizer, visit to: http://www.roseindia.net/java/example/java/io/tokenizingjavasourcecode.shtml Thanks RoseIndia Team
Java - Java Interview Questions
it as System.out.println(); For more information on Java visit to : http://www.roseindia.net/java/ Thanks
java - Java Interview Questions
out = new BufferedWriter(fstream); out.write("Hello Java"); //Close
cms - Java Interview Questions
alfresco concepts in core java,webapplications and webservices).i haver some information in net,i want how to implement alfresco in core java
urgent - Java Interview Questions
display the url one by one.using core java technology (e.g)when am requesting...://www.roseindia.net/java/example/java/io/file-url-download.shtml Thanks
Java - Servlet Interview Questions
Difference between server and application server for Java  What is the difference between server and application server for Java?  Hello,Here is the differenceWeb server:* Servers Static contents* Directly receives
Core Java Interview questions and answers
Core Java Interview questions and answers  .... So, we have tried to create most frequently asked Core Java Interview Questions and answers in one place. These Core Java Interview Questions are supported
questions
questions  what is emp table?? can u say what are the number 1 books for refering to java
questions
questions  what is emp table?? can u say what are the number 1 books for refering to java
questions
questions  what is emp table?? can u say what are the number 1 books for refering to java
questions
questions  what is emp table?? can u say what are the number 1 books for refering to java
questions
questions  what is emp table?? can u say what are the number 1 books for refering to java
questions
questions  what is emp table?? can u say what are the number 1 books for refering to java

Ads