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 |
Is object a data type in java?
What are encapsulation, inheritance and polymorphism?
Which is the class in java?
what is singlton class?where it is use in real time senario.
What are Transient and Volatile Modifiers?
3 Answers SAP Labs, TUP Manila,
What is meant by null and void?
Have you ever used hashtable and dictionary?
Is hashset ordered?
What is the use of parse function in java?
Explain the key functions of data binding?
0 Answers Akamai Technologies, Aspire, Impetus, Infogain, Tavant Technologies, Virtusa,
What are other modifiers?
I have a sorting issue with a Hashmap. My constraint is that I MUST use the Hashmap and work with existing code. I do a database query and place the results in a Hashmap. When I iterate thru the Hashmap, it loses the original alphabetical sorting done by the database. So, my problem is that I must sort the results coming out of the Hashmap which is then placed into another class.