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
Explain the transient field modifier?
List some important characteristics on jre
What is difference between adapter class and listener?
What is final method?
What is classpath?
Differentiate between overriding and overloading cases?
Why is singleton class used?
Can we use both this () and super () in a constructor?
What is t in generics in java?
What is the biggest integer?
Which is faster call by value or call by reference?
What is the purpose of garbage collection in java? When is it used?
Explain yield() method in thread class ?
What does += mean in java?
What is hashset in java?