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 use of javap tool.

1144


What is difference between variable declaration and definition?

978


What is the hashcode () and equals () used for?

1039


When we should use serialization?

1032


give an example for encapsulation?

1054


What are basic keywords?

1045


Is java code slower than native code?

1074


What is the main functionality of the remote reference layer?

2001


What classes of exceptions may be caught by a catch clause in java programming?

1181


What is a line break example?

1005


Why to use nested classes in java? (Or) what is the purpose of nested class in java?

1076


How many bits is a string?

1011


Define packages in java?

1009


Which access specifier can be used with class ?

1004


What is the difference between path and classpath variables?

1059