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 are different types of control structures?
What is the purpose of default constructor?
What is a wrapper method?
Is this valid in java ? Can we instantiate interface in java?
What do you mean by constructor?
What is generic class?
Explain about procedural programming language or structured programming language and its features?
How do you clear an arraylist in java?
What is a map in java?
What is purpose of applet programming?
What is jar?
Explain features of interfaces in java?
Which programming language is best in future?
Explain polymorphism citing an example.
Give us a program to check for parenthesis matching using stack.