• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S Multiple RandomAccessFiles working on the same file

 
Jim Petersson
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Is it possible to have several RAF's working on the same File concurrently?

For instance client A wants to update record 1, and client B wants to update record 2. If both of them have a separate RAF and I only lock on single records, this could be done in parallell.
However what will happen when I try to update my File with two differetn RAF's at the same time? I'm thinkning this might not work / be safe? (even though they are writing to different parts of the file)

If this doesn't work, then there's really no need to be able to lock on individual records is it? (Since I would need to lock on the file anyway).

Thanks
 
Matthew Flint
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Petersson:
Is it possible to have several RAF's working on the same File concurrently?

RandomAccessFile isn't threadsafe.

Originally posted by Jim Petersson:
If this doesn't work, then there's really no need to be able to lock on individual records is it? (Since I would need to lock on the file anyway).

I don't know about B&S, but for URLyBird there is a need to lock individual records, because the assignment says it "must" be done.

Matthew
 
Jim Petersson
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Matthew Flint:

I don't know about B&S, but for URLyBird there is a need to lock individual records, because the assignment says it "must" be done.

Matthew


Yes it's the same for B&S, but if its not possible to do multiple writes to one File (using different RAF's), then I would need to syncronize my methods that are dealing with the File anyway. (and using a singleton Data-class).

I'm just saying that even though I would implement locking on individual records (as is a must). It will not work, unless I do some more locking/syncronization. So in practice only one record can be altered at the same time.
Or am I missing something here?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic