• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Access from Servlets - Concurrency

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I need to access a file for read/write from two different servlets. How can i ensure concurrency ?i.e I dont want the file to be accessed by one servlet while it is being written into by another.
Thanks in advance.
 
henley
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick suggestion would be to pull out the code that creates or obtains the handle to the file and put it in a separate class as a static method. This way, each servlet can use this code and it can be synchronized to ensure concurrency.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I agree. Make sure you synchronize.
jashman
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic