what is the difference between sleep() and Wait()?
Answer Posted / amitasite
Thread.sleep() is static method which make current running
thread "not runnable" for specific time. Sleeping thread
doesn't release lock. It will transit to "ready to run"
state after specified time elapsed or other thread interrupts.
wait() can be call on shared object. Wait can be call only
if thread has lock. On calling thread it releases lock on
object and transit to "not runnable" state. It wake ups and
transit to "ready to run" state after other thread that got
lock call notify() or notifyAll() on shared object or call
interrupt().
| Is This Answer Correct ? | 11 Yes | 1 No |
Post New Answer View All Answers
How does hashset work in java?
How do you execute a thread in java?
In the below example, how many string objects are created?
What is meant by the value of a variable?
how a programmer confirms that the data submitted has been succesfully inserted into the database(either oracle or my sql).. How a programmer confirm if there is any problem with the program he wrote for insertion... ANS:--- >executeupdate method is having boolean return type, if anything goes wrong in data insertion or data updation, it would return false. otherwise, if it successfully inserts data into the database, it would return true NOW HOW TO I CHECK IN MY DURING EXECUTION WHETHER IT RETURNS TRUE OR FALSE... WELL IT WILL DISPLAY ANY MESSAGE OR NOT
Explain the importance of finalize() method.
What are the basic interfaces of java collections framework?
Why are getters and setters used?
What is the base class in java from which all classes are derived?
What is ide with example?
Why is string buffer better than string ?
Explain Basics of OOP Language in java
What does file separator do in java?
Explain java coding standards for constants?
What is the purpose of abstract class?