aspose file tools*
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 Spring in Action this week in the Spring 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: 203
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: 203
Thank you Jose and Roger for helping me solve the question.

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