• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Concurrency

 
Venkat Sidh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to handle file concurrency if two different applications (different JVM's) try to edit same file. What is the best way to handle this scenario. Thanks.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ideally when one file is open in write mode another process should be able to overwrite that file. However the more clean way is to use FileChannel and FileLock classes in java.nio packages. All you have to do is


lock() is a blocking method. You can use tryLock() version which doesn't block the call.
 
Venkat Sidh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Purushothaman. Let me try out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic