<commit_before>package com.lmax.disruptor.example;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.LifecycleAware;
import com.lmax.disruptor.TimeoutException;
import com.lmax.disruptor.dsl.Disruptor;
import com.lmax.disruptor.support.LongEvent;
import com.lmax.disruptor.util.DaemonThreadFactory;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class WaitForShutdown
{
    private static volatile int value = 0;

    private static class Handler implements EventHandler<LongEvent>, LifecycleAware
    {
        private final CountDownLatch latch;

        public Handler(CountDownLatch latch)
        {
            this.latch = latch;
        }

        @Override
        public void onStart()
        {
        }

        @Override
        public void onShutdown()
        {
            latch.countDown();
        }

        @Override
        public void onEvent(LongEvent event, long sequence, boolean endOfBatch) throws Exception
        {
            value = 1;
        }
    }

    public static void main(String[] args) throws TimeoutException
    {
        Disruptor<LongEvent> disruptor = new Disruptor<LongEvent>(
            LongEvent.FACTORY, 16, DaemonThreadFactory.INSTANCE
        );

        CountDownLatch shutdownLatch = new CountDownLatch(1);

        disruptor.handleEventsWith(new Handler(shutdownLatch));
        disruptor.start();

        long next = disruptor.getRingBuffer().next();
        disruptor.getRingBuffer().get(next).set(next);
        disruptor.getRingBuffer().publish(next);

        disruptor.shutdown(10, TimeUnit.SECONDS);

        System.out.println(value);
    }
}
<commit_msg>Shutdown example - wait for latch.<commit_after>package com.lmax.disruptor.example;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.LifecycleAware;
import com.lmax.disruptor.TimeoutException;
import com.lmax.disruptor.dsl.Disruptor;
import com.lmax.disruptor.support.LongEvent;
import com.lmax.disruptor.util.DaemonThreadFactory;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class WaitForShutdown
{
    private static volatile int value = 0;

    private static class Handler implements EventHandler<LongEvent>, LifecycleAware
    {
        private final CountDownLatch latch;

        public Handler(CountDownLatch latch)
        {
            this.latch = latch;
        }

        @Override
        public void onStart()
        {
        }

        @Override
        public void onShutdown()
        {
            latch.countDown();
        }

        @Override
        public void onEvent(LongEvent event, long sequence, boolean endOfBatch) throws Exception
        {
            value = 1;
        }
    }

    public static void main(String[] args) throws TimeoutException, InterruptedException
    {
        Disruptor<LongEvent> disruptor = new Disruptor<LongEvent>(
            LongEvent.FACTORY, 16, DaemonThreadFactory.INSTANCE
        );

        CountDownLatch shutdownLatch = new CountDownLatch(1);

        disruptor.handleEventsWith(new Handler(shutdownLatch));
        disruptor.start();

        long next = disruptor.getRingBuffer().next();
        disruptor.getRingBuffer().get(next).set(next);
        disruptor.getRingBuffer().publish(next);

        disruptor.shutdown(10, TimeUnit.SECONDS);

        shutdownLatch.await();

        System.out.println(value);
    }
}

{'fraction_non_alphanumeric': 0.08932208321210358, 'fraction_numerical': 0.004073319755600814, 'mean_word_length': 2.657446808510638, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6646089', 'n_tokens_mistral': 1030, 'n_tokens_neox': 988, 'n_words': 194}