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
What is a java developer salary?
Why packages are used?
Explain the key functions of data binding?
What is a prefix function.write down a code to compute prefix function.
What is the default size of arraylist in java?
What is variable length arguments in java?
Difference between Linked list and Queue?
Explain the importance of import keyword in java?
What is object class in java?
What do you mean by append?
What are the 4 versions of java?
What is string and example?
How an object is serialized in java?
What is ellipsis in java?
In java, what is the difference between method overloading and method overriding?