All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nerdvision.test.ResettableCountDownLatch Maven / Gradle / Ivy

The newest version!
package com.nerdvision.test;

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

public class ResettableCountDownLatch
{
    private final int initialCount;
    private volatile CountDownLatch latch;


    public ResettableCountDownLatch( int count )
    {
        initialCount = count;
        latch = new CountDownLatch( count );
    }


    public void reset()
    {
        latch = new CountDownLatch( initialCount );
    }


    public void reset( int count )
    {
        latch = new CountDownLatch( count );
    }


    public long getCount()
    {
        return latch.getCount();
    }


    public void countDown()
    {
        latch.countDown();
    }


    public void await() throws InterruptedException
    {
        latch.await();
    }


    public boolean await( long timeout, TimeUnit unit ) throws InterruptedException
    {
        return latch.await( timeout, unit );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy