• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Explanation for Dead Lock

 
Sudharsan Ashwin
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Can anyone explain, how deadlock occurs here?
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4116
195
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sudharsan Ashwin
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But only one thread at a time, can execute bow method right?
Then, how come gaston is also executing bow method?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic