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...

Why sleep()is in Thread and wait() in Object class? Why can't
I have both in one class or vice versa?

Answer Posted / ismail

In Java "Object" class is super for all classes and every
entity we consider as object in java. Every object in java
has default behaviour of "Object" class.

Now come to the point, When you instantiate a thread you
may require to stop a while that particular thread.So
Thread class has sleep method.

But in the situation of multithreading, you may require wait
() and notify() methods so that you can invoke "Object"
class behavior to your class.

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the transient field modifier?

962


List some important characteristics on jre

1030


What is difference between adapter class and listener?

968


What is final method?

1014


What is classpath?

955


Differentiate between overriding and overloading cases?

1040


Why is singleton class used?

983


Can we use both this () and super () in a constructor?

964


What is t in generics in java?

1001


What is the biggest integer?

998


Which is faster call by value or call by reference?

864


What is the purpose of garbage collection in java? When is it used?

997


Explain yield() method in thread class ?

1002


What does += mean in java?

1016


What is hashset in java?

1059