Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static RandomAccessFile variable or non-static one

 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Steven Hoodless
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic