This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Q on Kathy's Mock Test (Tpoic:Threads) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Q on Kathy Watch "Q on Kathy New topic
Author

Q on Kathy's Mock Test (Tpoic:Threads)

Reshma Shanbhag
Ranch Hand

Joined: Sep 17, 2002
Posts: 202
Hi All,
Which two donot cause a Thread to stop being the currently running thread?

A. calling the join() on a live thread
B. calling the sleep()
C. calling the wait()
D. calling the notify()
E. Entering an unlocked, sunchronized block of code.
Are the options A & E correct ?
Calling a notify() or notifyAll() releases the lock on the thread?
Help me
reshma
[ April 02, 2003: Message edited by: Reshma Pai ]
[ April 02, 2003: Message edited by: Reshma Pai ]

SCJP 1.4, SCWCD 1.4
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
join can result in the current thread's detention only if the thread on which join was called has started and not ended yet.
sleep and wait will always cause current thread's detention.
notify wil never cause it.
a synchronized block whose lock is not hold by any other thread will not prevent a thread from executing it.
wait releases the monitor, notify not.
You can find more information in the Java Tutorial at java.sun.com and the API.
[ April 02, 2003: Message edited by: Jose Botella ]

SCJP2. Please Indent your code using UBB Code
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Four methods cause a Thread to back out of running: Thread.sleep, Thread.yield, wait and join. The answer is therefore D and E.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Reshma Shanbhag
Ranch Hand

Joined: Sep 17, 2002
Posts: 202
Thank you Jose and Roger for helping me solve the question.

Reshma
 
jQuery in Action, 2nd edition
 
subject: Q on Kathy's Mock Test (Tpoic:Threads)
 
Similar Threads
Question on Wait() method
Q on Kathy's Mock Test (Topic:encapsulation)
threads
setPriority method on a thread object directly cause a thread to stop executing ?
Urgent -- Q on Comparator