This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

[URLyBird]Why dead lock?

 
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 ]
 
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • 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?
 
He does not suffer fools gladly. But this tiny ad does:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic