-1 will lock whole db. do we need to lock all the records one by one (wait for record to unlock if it is already locked)? i mean, do we need to implement just above step (is it so simple) or i am missing something.
Hi, I think you need to lock one by one as you imagine. If record 5 is already locked by some client, obtaining a lock of -1 does not seem to help. You may have other implementation, feel free to comment. Cheers.
hello, I don't think that lock-1 need to lock every record one by one. I design three database status: LOCKED NORMAL LOCKING. Just assign the status to Database. when there are any records are being locked, the lock-1 must wait. IF the database status is LOCKED or LOCKING, all the records lock action should be rejected. hope helpful stephen
As I understand it, the lock() method is supposed to block until it can actually lock the requested record. So if you start locking all the records because of a lock(-1) call then what happens to any remote clients that attempt to lock a record? Unless you throw an exception, they'll just sit there waiting for the record when it may be that the record will not be unlocked because the server is shutting down. Seems to me that you'd want the lock() method to throw some kind of ServerShuttingDownException so the client can handle it as gracefully as possible. I'm not sure that throwing an exception is the "best" way to handle it, but I think it's better than allowing the client to sit and wait until the user gives up and shuts it down. Comments, anyone?
SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
I AM MIGHTY! Especially when I hold this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!