Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

About server auto release

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,All
I met a new problem. I create a thread which will repeatly run in the server to check if there is overtime locks on server. If there are such locks, this thread will release the lock and notifyAll().
BUT, In this scene, Client A locked record 1 but didn't unlock it and A crashed. Client B tried to lock record 1 but found the record had already locked by other so thread of Client B was wait(). AND NOW, the thread I mentioned before found there is a overtime lock(of record 1) and release the lock. BUT when this thread notifyAll(), it can not call the Thread of Client B from wait to run.
I have tried many way but found only notifyAll() from Remote(through RMI) can let the wait thread(from remote too) from wait to run. Thread on server can not notify the threads called by Client from remote.
Can somebody supplied a solution to resolve the problem of the perivous scene.
Thanks in advance!
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, song
i use locktime(System.currentTimeMills()) as my value in a hashtable(the key is recordnumber), so in lock() method, i add a new monitor thread which persist in monitoring that hashtable. the thread will delete over-long time record and notifyAll when it find that hashtable has a over-long time record. the thread is in lock() method, and only once run.
how you implement your lock/unlock? Using a hashtable? if so, what is value, locktime, or other?
my english is bad, but i hope you can understand what i said.
thanks.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not quite sure I follow you. The notifyAll() called by your reaper thread should wake up the thread that handles the call from client B just fine -- it's a Thread like any other, really.
Are you sure you are calling notifyAll() on the same object that the calling thread wait()s on?
- Peter
 
Always! Wait. Never. Shut up. Look at this tiny ad.
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic