Code example for ScheduledThreadPoolExecutor

Methods: setMaximumPoolSize

package com.netifera.platform.ui.updater; 
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class TaskScheduler { 
	private static final TaskScheduler instance = new TaskScheduler();
	private final ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
	private TaskScheduler() { 
		/* we want only one thread */ 
		executor.setMaximumPoolSize(1); // not useful since ScheduledThreadPoolExecutor has PoolSize fixed
	public static TaskScheduler getInstance() { 
		return instance;
	public void remove(ScheduledTask scheduledTask) {
		ScheduledFuture<?> future = scheduledTask.getFuture();
		if(future != null) {
Connect your IDE to all the code out there  Get Codota for Java