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 Deadlock 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 "Deadlock" Watch "Deadlock" New topic


Sudhanshu Mishra
Ranch Hand

Joined: May 28, 2011
Posts: 235

Hi all,
I am a bit confused about following code's output.

Why a deadlock is not happening,because the main method has locked td and hence after td.start(),the run method should have a lock on td.But the point is that does the run method ever has a lock on td,or is it the XMap object?

Please clarify...

Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

You are right, the run method obtains the lock on the XMap object not the Thread object...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link:
subject: Deadlock
It's not a secret anymore!