Ordinary java.io does not support file locking. However, Windows lets you lock files for exclusive use. In particular, it locks active DLLs (Dynamic Link Libraries) from modification or deletion. The only way to get rid of such a file is to wait until the next reboot and before the file in put into use again and modify or delete it. You will see installers and uninstallers doing this. You can do it yourself manually with Microsoft’s Inuse Utility.
When a program crashes, Windows sometimes fails to release its file locks. Usually rebooting clears them.
OH.exe, part of the XP resource toolkit will tell you which process has locked a file.
Starting with Java 1.4, there is the java.nio.channels. FileLock class. 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. There are so many excuses in the docs for how they are not guaranteed to work, they sound all but useless.
You can roll your own primitive locks using the presence or absence of tiny locked-indicator files to indicate when a main file is in-use. Use File. createNewFile which as the nice property it atomically creates a new, empty file named if and only if a file with this name does not yet exist. You can even implement such a scheme in bat file language to prevent more than one instancte of any app from running at once. See the bat files to control the bulk email program.
This page is posted
Optional Replicator mirror
Your face IP:[22.214.171.124]
You are visitor number|