net.yudichev.jiotty.common.lang.CompositeRunnable Maven / Gradle / Ivy
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