Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multithreading madness! ;)

 
Adam Roberts
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I'm almost done with this thing but I've hit a little bit of a road block.
My locking mechanism works great, except during the shutdown process. I've tried several things and still end in dead lock or other errors. I'm using the wait() method to handle client requests and timers to dispose of stale locks. When the server calls lock(-1) and encounters a lock, it of course hits wait(). This causes the server thread to stop(well, they are waiting) the timers, and the locks never die.
I've tried doing something like

but this creates odd errors. First of all, when I attempt to shut the DB down with no locks on it, it only locks a seemingly random number of records. Second, whenever it encounters a lock( and a wait() request ), the thread simply dies.
Any ideas here?
I had another thought about creating a administrator client that would be used to lock the database, but wonder if I'll get docked points for the work around as I would have two programs running for the server.
Any thoughts would be helpful
Thanks
[ April 11, 2002: Message edited by: Adam Roberts ]
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might well be on the right track with threading problems, but it is very hard to say anything without seeing code. Can you cut the relevant code down to a postable size?
- Peter
 
Adam Roberts
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heres the lock function

...and the lockAll()

And finally the thread attempt(nested in an actionListener)

 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Adam,
instructions about lock() method says,
if the method is called with an argument of -1, the entire db should be locked.
regards,
bhuvan.
 
Adam Roberts
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats taken care of in my data class...
If its -1, it calls lockAll()
:roll:
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam,
Can you try locking the object that contains the lock method you've posted instead of the objects it uses.
 
Adam Roberts
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oooh :0
Thanks for the idea
Possibly just have a boolean value to redirects calls/throws an exception after the flag has been switched?
ala


Any more ideas would be appreciated and thanks Sai
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic