0

hi,
I have a probelm,two thread from two different JVM's accessing the same file causing improper data for the 2 JVM's resulting in improper data.
If it same JVM i can go for synchronized block ,wil not happen with independent JVM.soluion pls?

2
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by Ezzaral
0

hi thanks for the reply can someone explain me more about the API for file locking

0

hi thanks for the reply can someone explain me more about the API for file locking

From FileChannel javadoc:

a file channel can be obtained from an existing FileInputStream, FileOutputStream, or RandomAccessFile object by invoking that object's getChannel method, which returns a file channel that is connected to the same underlying file.

The FileChannel has methods to obtain a FileLock object on all or part of a file channel. When no longer needed, FileLock.release() will release the lock.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.