This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Multithreading madness! ;) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Multithreading madness! ;)" Watch "Multithreading madness! ;)" New topic
Author

Multithreading madness! ;)

Adam Roberts
Ranch Hand

Joined: Mar 18, 2002
Posts: 71
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 ]

Adam Roberts - SCJP2, SCJD<br />insert witty something here
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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

Joined: Mar 18, 2002
Posts: 71
Heres the lock function

...and the lockAll()

And finally the thread attempt(nested in an actionListener)

Bhuvan mehra
Ranch Hand

Joined: Mar 29, 2002
Posts: 69
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

Joined: Mar 18, 2002
Posts: 71
Thats taken care of in my data class...
If its -1, it calls lockAll()
:roll:
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
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

Joined: Mar 18, 2002
Posts: 71
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multithreading madness! ;)