Java Programming - Threads - Discussion
Discussion Forum : Threads - General Questions (Q.No. 3)
3.
Which three are methods of the Object class?
- notify();
- notifyAll();
- isInterrupted();
- synchronized();
- interrupt();
- wait(long msecs);
- sleep(long msecs);
- yield();
Answer: Option
Explanation:
(1), (2), and (6) are correct. They are all related to the list of threads waiting on the specified object.
(3), (5), (7), and (8) are incorrect answers. The methods isInterrupted() and interrupt() are instance methods of Thread.
The methods sleep() and yield() are static methods of Thread.
D is incorrect because synchronized is a keyword and the synchronized() construct is part of the Java language.
Discussion:
5 comments Page 1 of 1.
Kartiki said:
6 years ago
Anyone explain in detail?
Aarti gupta said:
9 years ago
The java.lang.Object.notify() wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.
Aarti gupta said:
9 years ago
I don't get it for synchronized()
Anand Yadav said:
9 years ago
Notify is used to wake the thread which is in waiting state.
Nan said:
9 years ago
What notify do?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers