File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Explanation for Dead Lock 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 "Explanation for Dead Lock" Watch "Explanation for Dead Lock" New topic
Author

Explanation for Dead Lock

Sudharsan Ashwin
Greenhorn

Joined: Mar 09, 2010
Posts: 18


Can anyone explain, how deadlock occurs here?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3164
    
  47

Please QuoteYourSources


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5



SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Sudharsan Ashwin
Greenhorn

Joined: Mar 09, 2010
Posts: 18
But only one thread at a time, can execute bow method right?
Then, how come gaston is also executing bow method?
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6662
    
    5

The lock is on the instance of the Friend object and not on the instance of Friend.class object. There are 2 friend objects. Locking on one does not prevent the other instance from executing the method.
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Sudharsan Ashwin wrote:But only one thread at a time, can execute bow method right?
Then, how come gaston is also executing bow method?


Lock is for object, not for methods!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Explanation for Dead Lock