Poison

FileLock

File locks are held on behalf of the entire Java virtual machine. They are not suitable for controlling access to a file by multiple threads within the same virtual machine.

References

FileLock (Java Platform SE 8 )
OverlappingFileLockException (Java Platform SE 8 )
Is FileLock in java safe across multiple threads within the same process or between different processes or both?
Example of inter-process and inter-thread file locking in Java · GitHub