Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

deadlock  RSS feed

 
Ramm Kummar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain the deadlock here.

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the necessary conditions for a deadlock. Can you see how they might be satisfied here?
 
Campbell Ritchie
Sheriff
Posts: 55284
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for us beginners. Moving.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is 'bobz's post on the Sun Java Forums on the same subject: deadlock

Ramm, generally we would rather you not crosspost your question on multiple forums, because it wastes peoples time going over territory that has already been covered. If you find one forum not responding (or perhaps giving confusing/inappropriate answers) by all means post someplace else to get better answers but you should be forthright and let us know.
 
Sean Doherty
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok Imagine a scenario where two threads for simplicity's sake lets name them threadA and threadB access the supposedly thread safe class "DeadLock" :-)

1. Lets say threadA calls the read() method the same time threadB calls the write method.
2. threadA gets a lock on resourceA, while threadB gets the lock on resourceB.
3. threadA holds the lock and tries to acquire the lock on resourceB
4. At the same time threadB holds the lock and tries to acquire the lock on resourceA

Hence the deadlock!

Cheers...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!