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 java console application?
What is a get method?
What is the use of an interface?
What is an escape character in java?
What are the types of literals?
What does super()represent, and how is it used in Java?
Does unicode support all languages?
Where can I find data structures question and answers with comprehensive working code written in Java
Can you call one constructor from another if a class has multiple constructors?
Can we have multiple catch block for a try block?
What is variable and example?
How to perform quicksort in java?