2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.clustering.it.provider.impl;
10 import java.util.concurrent.ScheduledThreadPoolExecutor;
11 import java.util.concurrent.TimeUnit;
14 * A simple ScheduledExecutorService, which shuts down its threads after a period of inactivity. It is safe to not
17 * @author Robert Varga
19 final class FinalizableScheduledExecutorService extends ScheduledThreadPoolExecutor {
21 private FinalizableScheduledExecutorService(final int maxThreads, final long time, final TimeUnit unit) {
23 setKeepAliveTime(time, unit);
24 allowCoreThreadTimeOut(true);
27 static ScheduledThreadPoolExecutor newSingleThread() {
28 return new FinalizableScheduledExecutorService(1, 15, TimeUnit.SECONDS);
31 // This is a bit ugly, but allows
33 @SuppressWarnings("checkstyle:NoFinalizer")
34 protected void finalize() {