2 * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.ovsdb.utils.mdsal.utils;
10 import com.google.common.util.concurrent.ThreadFactoryBuilder;
12 import java.util.concurrent.Executors;
13 import java.util.concurrent.ScheduledExecutorService;
14 import java.util.concurrent.ThreadFactory;
15 import javax.inject.Singleton;
18 public class Scheduler implements AutoCloseable {
19 private static final ThreadFactory NAMED_THREAD_FACTORY = new ThreadFactoryBuilder()
20 .setNameFormat("ovsdb-sched-%d").build();
21 private static final ScheduledExecutorService SCHEDULED_EXECUTOR_SERVICE
22 = Executors.newSingleThreadScheduledExecutor(NAMED_THREAD_FACTORY);
24 public static ScheduledExecutorService getScheduledExecutorService() {
25 return SCHEDULED_EXECUTOR_SERVICE;
30 SCHEDULED_EXECUTOR_SERVICE.shutdown();