2 * Copyright (c) 2013 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.config.threadpool.util;
11 import java.io.Closeable;
12 import java.util.concurrent.Executors;
13 import java.util.concurrent.ScheduledExecutorService;
14 import java.util.concurrent.ScheduledThreadPoolExecutor;
15 import java.util.concurrent.ThreadFactory;
16 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
19 * Implementation of {@link ScheduledThreadPool} wraps
20 * {@link ScheduledExecutorService}.
22 public class ScheduledThreadPoolWrapper implements ScheduledThreadPool, Closeable {
24 private final ScheduledThreadPoolExecutor executor;
25 private final int threadCount;
27 public ScheduledThreadPoolWrapper(int threadCount, ThreadFactory factory) {
28 this.threadCount = threadCount;
29 this.executor = new ScheduledThreadPoolExecutor(threadCount, factory);
30 executor.prestartAllCoreThreads();
34 public ScheduledExecutorService getExecutor() {
35 return Executors.unconfigurableScheduledExecutorService(executor);
44 public int getMaxThreadCount() {