# Lock File

{% hint style="warning" %}
**This is the manual for older MicroStream versions (Version < 5.0).**

**The new documentation (Version >= 5.0) is located at:**

[https://docs.microstream.one/](https://docs.microstream.one/manual)
{% endhint %}

By default, MicroStream uses the operation system's standard file locking mechanism to prevent simultaneous access to the storage files. In the rare case that this is not sufficient to control the file access MicroStream provides a proprietary file lock implementation to ensure exclusive access to the storage files from different applications using MicroStream.

Using this file lock may only be necessary if, while a MicroStream application is running, a second MicroStream application may try to access the same storage and the default file locks are not reliable.

You don't need to activate this feature if:

* Only one MicroStream application will access the storage,
* MicroStream applications that may access the same storage run on the same system,
* other applications that may access the storage files don't use MicroStream to access them.

To activate the internal file lock you need to setup `StorageLockFileSetup`:

```java
EmbeddedStorageManager storageManager = EmbeddedStorage
	.Foundation()
	.setLockFileSetupProvider(Storage.LockFileSetupProvider())
	.start();
```

The default interval the locks are updated is 10 seconds, you can set a custom value in milliseconds with:

`Storage.LockFileSetupProvider( final long updateInterval )`

To specify the charset used by the lock files use:

`Storage.LockFileSetupProvider( final Charset charset )`

or, to customize both:

`LockFileSetupProvider( final Charset charset , final long updateInterval )`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.docs.microstream.one/data-store/configuration/lock-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
