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

net.yudichev.jiotty.common.lang.CompositeRunnable Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package net.yudichev.jiotty.common.lang;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public final class CompositeRunnable implements Runnable {
    private final List delegates = new CopyOnWriteArrayList<>();

    @Override
    public void run() {
        CompositeException.runForAll(delegates, Runnable::run);
    }

    public Closeable add(Runnable runnable) {
        delegates.add(runnable);
        return Closeable.idempotent(() -> delegates.remove(runnable));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy