Originally posted by joel smither:
Thanks for the info Peter.
My Data class has the readRecord, createRecord, updateRecord methods that do the low level I/O (i.e. the seek to the proper position in the file, actual read and write, etc). Don't I need to synchronize any method that does an fseek because 2 clients could seek at the same time?
Also, with respect to the LockManager....all the methods in my LockManager class are synchronized...the methods in th class use a Hashmap to maintain information on which records are locked. The Hashmap is not a synchronzied collection, I just have a synchronized lock and unlock method in the LockManager class.
Does anyone see any problems with this approach?
Originally posted by joel smither:
Instead of synchronizing on the RAF, can't I just synchornize the methods that do a fseek, file write, file read, etc. I don't understand the difference? If the methods are synchronized that means only one method is using the file at a time right?
Also, when you say synchronize on the Hashmap, you're talking about a sunchronized block like:
synchronized(Hashmap)
{
...
}
what's the difference between using the synchronized block and having the methods in the LockManager class be synchronized. It seems they are doing the same thing...?
SCJP 1.4, SCJD
Don't get me started about those stupid light bulbs. |