wood burning stoves*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 3011
    
  34

Please QuoteYourSources


Founder of ExamLab and Systemup
See how I can help you to become an awesome programmer
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    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: 6661
    
    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
 
Similar Threads
Why first output is second output
Question on Synchronized mehods
[B]Class Monitor Vs. Object Monitor[/B]
I'm confused with the deadlock exampl in Java Tutorial.
Deadlock