Hello everyone. I see most people in this forum using a static RandomAccessFile variable on both singleton and non-singleton Data class, but I don't understand that why they have the static RAF instead of a local RAF variable? Please anyone tell me. Thank you, Surasak Lee
Hey there. I also used a singleton Data object approach, but I used a local private member raf. I also don't see the benefit of having the raf static. It makes no difference in mi opinion. Perhaps I am wrong... Somebody tell us. J
It depends on your file-access mechanism. For example, you may have multiple Data classes all sharing access to one static RandomAccessFile. By locking on the static RAF you can prevent multiple synchronous access from corrupting the file. Steven
SCJP, SCJD, SCWCD.
Joined: Dec 18, 2003
That makes sense. But what I'm talking about is a static raf versus a non-static raf within a Data singleton. No benefit as far as I can see.