Search code examples
javajava-7filelock

what happens with FileLock on JVM crash?


I'm just wondering what happens with a lock from FileLock, if a JVM crashes hard or it gets a SIGKILL.

Nothing in the FileLock doc is specified about it, so I assume it is released. Just want to make sure, though...

Thx


Solution

  • Presumably the same as with any other program that crashes, which is platform dependent. As the api doc states, FileLock just uses the native locking mechanism available on the platform you run on:

    This file-locking API is intended to map directly to the native locking facility of the underlying operating system.

    See also this answer to a similar question.