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

What is the default value of byte datatype in java?

0 Answers  


What is module with example?

0 Answers  


Functionality of JVM?

7 Answers   Infosys,


What is OOP?

2 Answers   BMC, Microsoft,


Explain the difference between static and dynamic binding in java?

0 Answers  






Explain pass by reference and pass by value?

8 Answers   IBM, Wipro,


How can we achieve IPC in JAVA?

1 Answers   Wipro,


What are encapsulation, inheritance and polymorphism?

0 Answers  


What are different access specifiers in java? Explain

0 Answers  


Is array dynamic in java?

0 Answers  


Explain about oops concepts.

0 Answers   Aditi Placement Service,


what are the difference between Java and .Net?

5 Answers  


Categories