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

What is stored procedure. How do you create stored procedure ?

1987


How many types of constructors are used in java?

1271


Can a source file contain more than one class declaration?

1058


What is the integer of 16?

1039


Write a program to reverse a number in java?

1134


How finally used under exception handling?

988


Explain the importance of join() method in thread class?

1137


What is variable length arguments in java?

1036


Why arraylist is used in java?

1119


What is a lock or purpose of locks in java?

1089


What are constants?

1104


What is sortedmap in java?

1080


Can list contain null in java?

1146


How does varargs work in java?

1144


Which are the two subclasses under exception class?

1169