This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes File Concurrency Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "File Concurrency" Watch "File Concurrency" New topic
Author

File Concurrency

Venkat Sidh
Ranch Hand

Joined: Sep 30, 2006
Posts: 61
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

Joined: May 24, 2003
Posts: 425
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

Joined: Sep 30, 2006
Posts: 61
Thanks Purushothaman. Let me try out.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: File Concurrency
 
Similar Threads
SCJD J2SE Database Question
How does the Log file function in a multitude of environments?
Serialization topic covered in SCJP 6?
Caching of Database Access Objects's possible?
Concurrency issue