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 the purpose of a statement block?
How 'java' got its name and what it stands for?
what are variables in java
How do you find the independent variable?
What is the purpose of javac exe?
when everything can be done by static block then why do we use main method?.
What is exception and error? and what is the difference between them?
How we can skip finally block of exception even if some exception occurs in the exception block in java?
What is Marker interface in java? and what is clone?
write a program to create an arraylist and listeterator.and value should be enter through keyboard.
Is an object null?
What is a bubble sort in java?