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

How can you set an applet’s height and width as a percentage?

980


What is structure of java heap? What is perm gen space in heap?

1195


How to create com object in Java?

1123


How do you sort in descending order in java using collections sort?

973


What is import java util arraylist?

1251


Explain importance of inheritance in java?

1086


What are the two main uses of volatile in Java?

1098


What is a class component?

1228


What is the functionability stubs and skeletons?

1214


What is java object name?

1049


What is difference between string and stringbuffer?

1206


What is tostring () method?

1092


What is jvm? How its run?

1152


Can java program run without jre?

1065


What is final?

1140