• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[URLyBird]Why dead lock?

 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic