Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

For class CFoo { }; what default methods will the compiler generate for you>?

1026


What is a short in java?

966


What is jvm? How its run?

1021


Can subclass overriding method declare an exception if parent class method doesn't throw an exception?

1002


What is covariant return type?

1060


What is the concatenation operator in java?

1078


Define linked list and its features with signature?

933


what is enumset?

1045


What is object in java?

923


If you are given the name of the function at run time how will you invoke the function?

1080


Explain java coding standards for classes or java coding conventions for classes?

1062


Is treeset sorted in java?

936


Explain what are final variable in java?

1023


What is java thread dump, how can we get java thread dump of a program?

942


What's the access scope of protected access specifier?

991