This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi, My lock function does not seem to work as intended in seperate VMs. I am testing it by creating a lock and unlock button in my GUI that just has the lock /unlock code. I start the server and registry and that works ok. Then start one client in local mode on my machine and lock a recoed (say 12). Then open another DOS window and try to lock the same record. But it allows me to lock the same record.(It does not go into the wait code as I expected). As I understand RMI implements multithreading so I have not anywhere in my code implicitly started a new thread. Is that Ok?. Here is my code for the lock and unlock. Your comments would be much appreciated. How to mak ethis work properly on a separate VM
Regards Charu [ Please use CODE tags around code -- PdH ] [This message has been edited by Peter den Haan (edited September 26, 2001).]
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
posted
0
Your logic looks right to me - verify that the problem isn't elsewhere: is the record really locked, isn't it unlocked, are you looking at the same r_lock object, &c? Validation in lock() is a bit overenthusiastic - an IOException is thrown if record is -1 (database lock). Also, a synchronized Map is used for r_lock. You don't need a synchronized data structure however because you already have to explicitly synchronize access. And, as the code currently is, it really wants to be a Set. - Peter
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Locking not working properly in seperate VMs