Thanks for responding guys.
My raf doesn't get closed until the end, so I don't think that is the problem.
Here is my setup:
1. I have static synchronized Data.getInstance() method which gets my 1
instance (i.e. if null, generate the instance, else return the instance)?
**** this synchronization would be on the Class instance since static. Added this to prevent 2 threads from calling getInstance at the same time and inadvertently creating 2 instances of Data rather than my singleton.
2. My create, update, delete, read methods in Data are synchronized.
**** this synchronization would be on the Data instance, for the physical file locking
3. My logical record locking is very similar to Max, where I synchronize on
a lockedRooms HashMap in both lock and unlock.
I'm assuming I have a flaw somewhere, because RandomAccessFile should work fine if I get it set up right. Simply going to FileChannel is not going to fix this, right?
Is there any issue with kicking off a bunch of threads that all attempt to get the singleton Data instance and do stuff with it? For example, in my update multithread
test, each
thread will attempt the following:
At one point I actually grabbed the Data instance up front and sent it to each thread, but I was having a problem with that to and I thought it was because I was saving multiple pointers to the Data instance (i.e. one in each generated thread)
Any help appreciated!
TJ