Originally posted by Frans Janssen:
The most straightforward way is to create a Data class instance for every client and use the Data reference as a client identifier.
Aha! I did not even considering using 'this' as the client ID. Now though, I still have a single static instance of a RandomAccessFile object, and I am not sure how to initialize it in the constructor:
private static RandomAccessFile raf;
private static final rafMutex = new Object();
public Data(File file) {
synchronized (rafMutex) {
if (raf != null) { /* set raf using file */ }
}
}
Is there a better way? I ask because rafMutex will only be used once to
initilize and validate the raf the first time.
Update: on further examination, what about synchronizing on Data.getClass()? Would there be any problems with using that?
[ May 16, 2005: Message edited by: Titus Barik ]