File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread wait Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread wait" Watch "Thread wait" New topic

Thread wait

Sasikanth Malladi
Ranch Hand

Joined: Nov 04, 2000
Posts: 175
Which of the following statements are true. Select all correct answers.
A.The wait method defined in the Thread class, can be used to convert a thread from Running state to Waiting state.
B.The wait(), notify(), and notifyAll() methods must be executed in synchronized code.
C.The notify() and notifyAll() methods can be used to signal and move waiting threads to ready-to-run state.
D.The Thread class is an abstract class
Correct answers are: B and C. Why isn't A true?
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

wait() is defined in java.lang.Object. It's purpose is to allow any object (not necessarily a threaded one) to protect its internal data against "unordered" access.

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
parag bharambe
Ranch Hand

Joined: Sep 01, 2000
Posts: 41
wait() method is used to used to move the thread from runnig state to ready to run state. So IMO this is same as putting a current thread in waiting state.
SO i think A is also right ans.
Am i right? !
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
The point is that A says " defined in the Thread class". Therefore A is NOT right. No matter what the rest of the statement says.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: Thread wait
jQuery in Action, 3rd edition