Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[URLyBird]Why dead lock?

 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have finished my LockManager coding. While only one client booking, nothing abnormal. But more than one client booking the same room, the server application will deadlock as:
normal: only one client booking


Please help me.

[Andrew: Deleted methods - refer to SCJD FAQ for why.]
[ April 13, 2006: Message edited by: Andrew Monkhouse ]
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Your lockManager class is strongly coupled with your data access class.
My advice is try to make a lockManager implementation without dependencies, hidden behind an interface, this way your application will be more maintainable.
Why the lockManager has to know when a record is in deleted state?
Regards
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Oricio,


Why the lockManager has to know when a record is in deleted state?

If record 2 is already locked by clientA. Now clientB try to lock record 2, but find that record 2 has already in lockMap. Then clientB wait. A few milliseconds later, clientA deleted record 2 and unlock. Then record 2 was moved from lockMap. At the same time clientA is waked and find that record 2 is not in lockMap, then clientA lock record 2 and do some execution. While in fact, record 2 is no longer valid and can not be lock and executed.
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Because RMI created threads are not easy to control, I give up using wait and notifyAll. My choice now is sleep and test have already bone with my expected result. So everything seems easy using sleep. But I not sure whether using sleep will ail score?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic