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;
17 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
20 * Implementation of {@link ScheduledThreadPool} wraps
21 * {@link ScheduledExecutorService}.
23 public class ScheduledThreadPoolWrapper implements ScheduledThreadPool, Closeable {
25 private final ScheduledThreadPoolExecutor executor;
26 private final int threadCount;
28 public ScheduledThreadPoolWrapper(int threadCount, ThreadFactory factory) {
29 this.threadCount = threadCount;
30 this.executor = new ScheduledThreadPoolExecutor(threadCount, factory);
31 executor.prestartAllCoreThreads();
35 public ScheduledExecutorService getExecutor() {
36 return Executors.unconfigurableScheduledExecutorService(executor);
45 public int getMaxThreadCount() {