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



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

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

More Core Java Interview Questions

When is the finalize() called?

0 Answers  


what is Assertion?

4 Answers   Wipro,


What is pojo class in java?

0 Answers  


What is the difference between serial and throughput garbage collector?

0 Answers  


what is diffrence between .NET and java?

2 Answers  






Can we have try block without catch block?

0 Answers  


When does a class need a virtual destructor?

0 Answers   Flextronics,


how to transactions(Bank transactions) in business process in ejb?

1 Answers   Photon,


What happens if we don’t define serial version uid?

0 Answers  


Where are global variables stored?

0 Answers  


What are the differences between string and stringbuffer?

0 Answers  


Can we overload the constructors?

0 Answers  


Categories