• 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

Lock timeout

 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is everyone's opinion for a timeout period on a lock? Right now, I'm using 5 seconds which seem adequate but I'm not sure. Also should the owner of the lock be notified that the lock has been released after timing out? Do we just assume that the owner of a timed out thread has died? As I see it right now there is only a slight chance of data corruption if for some chance the owner of the timed-out lock is still alive.
Thanks,
Michael Morris
 
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Michael:
Why do you need timeout? Am I missing anything really good? I did not see any requirement on this? I did not use it.
My bottom line was their requirement which I really liked it, loved it. ...A clear design, such as will be readily understood by junior programmers, will be preferred to a complex one, even if the complex one is little more efficient than the simple choice.
It was my assumption that server crash, unpredictable clients, and unpredictable network
connections are not issues. So, I did not handle such extreme situation in SCJD's application.
What do you think? Does it sound good?
-Bal
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bal,
I see your point, but my timeout scheme consists of one interface, LockTimerCallback with one method which is implemented by my LockManager, and a LockTimer class which extends TimerTask and consists of less than 40 lines of code for the whole class. I feel the design is clear enough for a junior programmer to understand and maintain. I do respect your opinion and hope you continue to respond to my posts.
Thanks,
Michael Morris
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seen a few with timeouts, and it is a fine design. I would put it to a minute, just to be safe.
Most others have used the Unreference interface to handle stale clients, but a timeout feature is fine. Especially if it is implemented simply that that junior programmer can understand.
Mark
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark. Do you think using a roll-your-own callback scheme is OK? I thought about using a beans scheme (firePropertyChange or fireVetoableChange) but that would have been more complex than what I did. The plus side would be that it's built into the API.

Thanks again,
Michael Morris
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Do you think using a roll-your-own callback scheme is OK?


Well, you could always implement the Observable interface so that you can make your own callback scheme. The big question is can that Junior Programmer understand it?
Mark
 
Bal Sharma
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
..I feel the design is clear enough for a junior programmer to understand and maintain...
Hello Michael:
I think you are in right track. Now I believe, it is not complex too, Keep it up. And OH YEAH! I will try to respond everybody's posting as much as I can.
-Bal
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bal,
It's always nice to have the opinion of someone whose already made it to the top of the mountain.
You and Mark have already helped me fix some shortcomings in my initial design. I'm sure I will use your expertise again before I finish.
Thanks again
Michael Morris
 
reply
    Bookmark Topic Watch Topic
  • New Topic