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

How we can execute any code even before main method?

1187


What is the largest data type in java?

1021


What are the different types of sorting in java?

1024


Tell me how many ways are there to initialise an integer with a constant.

1154


What are triggers in DB? Explain their types. How do they work?

1138


What is meant by anonymous class?

1089


You're given a Boolean 2D matrix, can you find the number of islands?

1150


Which class is used by server applications to obtain a port and listen for client requests?

1018


What are heterogeneous objects?

1085


Why destructor is not used in java?

1032


Give reasons supporting that string is immutable.

998


How many types of equations are there?

1066


What is difference between path and classpath?

1268


How do you escape a string?

1037


What is a “stateless” protocol ?

1037