From a mock exam: Which of the following methods belong to an instance of Thread? wait() is one of the answer, the explanation is that Thread object is an Object so it has wait() method.
From a textbook: Which of the following methods are defined in class Thread? wait() is considered as a wrong answer.
I want to ask about the difference of the answer. Because wait() in Thread object is inherited from Object class where it is FIRST defined, so Thread object has a wait() method but doesn't define it. Am I correct? Thank You.
The idea here is that wait(), notify, and notifyall() methods belong to java.lang.Object, while other thread related methods such sleep(), yield(), join(), and setPriority(int a) belong to java.lang.Thread. So even though all objects (even Thread class objects) inherit from the Object class and can use its methods, but the methods of class Object such as wait() are part of the Object class. Further more these methods are final and so cannot be overrridden in subclasses.
hi, The Thread class itself implements Runnable interface, and provide an implementation of run(). The run method simply execute the run method of a runnable object that is passed through it through the constructor of the Thread. [ June 29, 2005: Message edited by: Vipin Das ]
Joined: Mar 26, 2005
there is a question under k&b book(exam 310-035& 310-025, page 540, question 2, about class Thread.
Which two of the following methods are defined in class Thread? A. start() B. wait() C. notify() D. run() E. terminate() -------------------- my first answer was "answer A. start()". i know the question ask me to choose TWO. but i dont understand why run() will also be the answer.
is it because Thread implements Runnable and then run() will be defined in class Thread since class Thread implements Runnable and have to provide the implementation?
my second time answering this question on the MasterExam questions i mark run() and start().
i hope i wont get wrong on this in my saturday test coming soon.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com