
be.bagofwords.application.BowTaskScheduler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bow-utils Show documentation
Show all versions of bow-utils Show documentation
Utility classes that are used in the count-db project and other bow-* projects
The newest version!
package be.bagofwords.application;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created by Koen Deschacht ([email protected]) on 14/11/14.
*/
public class BowTaskScheduler implements CloseableComponent {
private ScheduledExecutorService scheduledExecutorService;
/**
* @param task
* @param period In milliseconds
*/
public synchronized void schedulePeriodicTask(Runnable task, long period) {
if (scheduledExecutorService == null) {
scheduledExecutorService = Executors.newScheduledThreadPool(5);
}
scheduledExecutorService.scheduleAtFixedRate(task, 0, period, TimeUnit.MILLISECONDS);
}
@Override
public void terminate() {
scheduledExecutorService.shutdown();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy