it.auties.whatsapp.util.DeferredTaskRunner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of whatsappweb4j Show documentation
Show all versions of whatsappweb4j Show documentation
Standalone fully-featured Whatsapp Web API for Java and Kotlin
package it.auties.whatsapp.util;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
public class DeferredTaskRunner {
private final AtomicBoolean condition;
private final List deferredTasks;
public DeferredTaskRunner() {
this.condition = new AtomicBoolean(false);
this.deferredTasks = new ArrayList<>();
}
public void execute() {
condition.set(true);
deferredTasks.forEach(Runnable::run);
deferredTasks.clear();
}
public void schedule(Runnable runnable){
if(condition.get()){
runnable.run();
return;
}
deferredTasks.add(runnable);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy