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 / suresh

Yes, sleep() and wait() methods are doing same work like prevent Thread Execution some amount of time in different ways.

where wait() is used only in Synchronization area this is called on object.wait(), it is overloaded method.if a thread object calls wait() then that thread will release the lock and wait for notification( notify(), notifyAll()) after getting notification thread will make Runnable.

where as sleep() is used any where it is static method. when sleep() called then thread will enter into sleep state particular amount of time if time expires thread will move into Runnable or Ready state.

In both cases Thread will Interrupted by interrupt().It will checked Exception we have take care of that with try n catch or throws.

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can interface be private in java?

1026


What is a stack class in java ?

1107


What is super?

1166


Can a class be private?

962


what are abstract functions?

1029


Is singleton set an interval?

967


What are the 4 types of characters?

1014


What is the difference in between cpp and java? Can u explain in detail?

1091


Why are the destructors for base class and derived class called in reverse order when the program exits

2211


Can we sort list in java?

973


How static variable work in java?

1127


Why char array is preferred over string for storing password?

1106


Why put method is idempotent?

918


What is variable length arguments in java?

977


What is exception in java?

1087