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

What is a java developer salary?

536


Why packages are used?

540


Explain the key functions of data binding?

579


What is a prefix function.write down a code to compute prefix function.

534


What is the default size of arraylist in java?

498






What is variable length arguments in java?

510


Difference between Linked list and Queue?

602


Explain the importance of import keyword in java?

519


What is object class in java?

501


What do you mean by append?

530


What are the 4 versions of java?

553


What is string and example?

551


How an object is serialized in java?

522


What is ellipsis in java?

572


In java, what is the difference between method overloading and method overriding?

578