Originally posted by Ian B Anderson:
Hello,
If you were using RMI then your Remote object would have an instance of data (just one instance used by all connections).
Ian
True, as stated - but not the way you mean it Not only the File object, but also the file itself is not threadsafe, you need to single-thread access to it. Multiple Data objects (over the same file) are a big no-no.Originally posted by Robert Philip:
My experiments with the random access file lead me to think that the random access file is thread safe if you allow only one thread to access a given record (via an offset).
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Ian B Anderson:
If its RMI then you put 1 object on the rmiregistry and each client gets the same object how do you then assign them each an instance of Data. A connection class?
Ian
Originally posted by Peter den Haan:
[B]....but also the file itself is not threadsafe, you need to single-thread access to it. Multiple Data objects (over the same file) are a big no-no.
- Peter
B]
Ok, I did my homework this time and take back what I said. The important point is that RandomAccessFile is completely unbuffered; every read() or write() is directly translated into a kernel call. One would hope that a kernel handles this correctly (although as you note concurrent access to the same record certainly is not handled correctly). I am no longer convinced that this approach is thread-unsafe but, in the absence of decent documentation, I am not convinced that it is threadsafe on all platforms and JVMs either.Originally posted by Robert Philip:
Yes if you implement a record level lock each region of the random access file is access by a single thread. I have seen this design in major applications accessing flat files.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Never be satisfied with anything less than the best and you will surely pass the test...
Never be satisfied with anything less than the best and you will surely pass the test...
I don't even know how to spell CIA. But this tiny ad does:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|