In java.nio.channels.FileChannel any concurrent operations are blocked. It seems all operations are synchronized, but why do we use file lock to lock the file explicitly?
Asked
Active
Viewed 264 times
1 Answers
2
The file lock, locks the file from access by all programs.
The synchronized access to the FileChannel locks access to that object within the same program. If you use another FileChannel you can access the same file in a different thread.

Peter Lawrey
- 525,659
- 79
- 751
- 1,130
-
NB that according to http://stackoverflow.com/questions/4025721/java-file-locking the file lock on some OS's is seem as "advisory" only... – rogerdpack Aug 26 '13 at 17:13