0

I came across a class somebody else wrote that implements a file-backed FIFO using a RandomAccessFile.

The file is segmented into blocks with writes coming in from one thread and reads from another, both sharing the same RandomAccessFile object with locks to keep from trashing each others file pointers and such.

This whole design is giving me some serious concerns, but I'm hesitant to redesign code that isn't blatantly failing in the field.

1a - If the code writes a block in from one thread, and immediately reads it out from another, potentially before the write posts to the disk, will the read get the whole contents of the block? 1b - Does it matter whether the file is opened "rw" or "rwd?" 2 - Are there going to be volatility issues with two threads looking at the same RandomAccessFile object such that some members of the object are stale in one thread or the other?

TIA - Tim.

tbroberg
  • 635
  • 3
  • 11

0 Answers0