Why sleep()is in Thread and wait() in Object class? Why can't
I have both in one class or vice versa?
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 |
What is an accessor?
What is the primary benefit of encapsulation?
What is substring 1 in java?
Can an object?s finalize() method be invoked while it is reachable?
What is a parameter in simple terms?
Can we restart a dead thread in java?
Can you make a constructor final?
Can array grow dynamically in java?
java is fullu object oriented or pure? why?
what should do when using multiple catch() block & what should never do for the same?
What is void in java?
What do you mean by global variable?