I want to use one single RandomAccessFile
One should always use only a single writer to a file in general. Readers can be multiple. However, if you are using a single reader/stream then it will be aweful to allow two threads to access it concurrently. You can use FileLocks to ensure that only one thread reads a file(or part of it) at a time.
Having said the above, why do you want multiple threads to read from the same file instance? You can provide an entity(basically a wrapper over the RandomAccessFile) that fetches the data from the file and all the other components always refer to this entity to get the data. This entity can either read the data in one go and then have in-memory representation of the same OR it can sequentially allow people to read from the file. Also, it will help you to move to any other Stream implementation later without affecting the clients. It can have separate locks for reading and writing if the need be.
[ August 10, 2007: Message edited by: Nitesh Kant ]
[ August 10, 2007: Message edited by: Nitesh Kant ]