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

chao.java.tools.servicepool.thirdparty.CancelableCountDownLatch Maven / Gradle / Ivy

package chao.java.tools.servicepool.thirdparty;

import java.util.concurrent.CountDownLatch;

/**
 * As its name.
 *
 * @author Alex Contact me.
 * @version 1.0
 * @since 16/8/29 15:48
 */
public class CancelableCountDownLatch extends CountDownLatch {
    /**
     * Constructs a {@code CountDownLatch} initialized with the given count.
     *
     * @param count the number of times {@link #countDown} must be invoked
     *              before threads can pass through {@link #await}
     * @throws IllegalArgumentException if {@code count} is negative
     */
    public CancelableCountDownLatch(int count) {
        super(count);
    }

    public void cancel() {
        while (getCount() > 0) {
            countDown();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy