> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/gridgain/gridgain-8/gridgain8-development/data-structures/countdownlatch.md).

# CountDownLatch

IgniteCountDownLatch provides a distributed count-down latch that synchronizes operations across cluster nodes.

`IgniteCountDownLatch` provides functionality that is similar to that of `java.util.concurrent.CountDownLatch` and allows you to synchronize operations across cluster nodes.

A distributed CountDownLatch can be created as follows:

```java
Ignite ignite = Ignition.start();

IgniteCountDownLatch latch = ignite.countDownLatch("latchName", // Latch name.
        10, // Initial count.
        false, // Auto remove, when counter has reached zero.
        true // Create if it does not exist.
);
```

After the above code is executed, all nodes in the specified cache will be able to synchronize on the latch named `latchName`. Below is a code example of such synchronization:

```java
Ignite ignite = Ignition.start();

final IgniteCountDownLatch latch = ignite.countDownLatch("latchName", 10, false, true);

// Execute jobs.
for (int i = 0; i < 10; i++)
    // Execute a job on some remote cluster node.
    ignite.compute().run(() -> {
        int newCnt = latch.countDown();

        System.out.println("Counted down: newCnt=" + newCnt);
    });

// Wait for all jobs to complete.
latch.await();
latch.close();
```

{% hint style="info" %}
Remember to close the CountDownLatch after you are done with it to avoid keeping it in memory.
{% endhint %}
