This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

B&S Multiple RandomAccessFiles working on the same file

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic