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 do the thread?class methods run() and start() do?
What are data types in programming?
What is a “stateless” protocol ?
List implementations of list interface?
WAP to illustrate the use of interface
What is difference between iterator access and index access?
What is the size of boolean variable?
diffrence b\w println() and printf()
What is http client in java?
what is meant by encapsulation?
What is the use of generics? When was it added to the Java development Kit?
What is better - 'bit-shift a value' or 'multiply by 2'?