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.
|
|
You can get the freshest copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) |
| http://mindprod.com/jgloss/lockedfiles.html | J:\mindprod\jgloss\lockedfiles.html | |
![]() | Please email your feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording,
broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Canadian Mind Products | ||
| mindprod.com IP:[65.110.21.43] | ||
| view Blog | Your face IP:[38.107.179.212] | |
| Feedback | You are visitor number 10,868. | |