All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tarantool.driver.core.TarantoolDaemonThreadFactory Maven / Gradle / Ivy

Go to download

Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework

There is a newer version: 0.14.0
Show newest version
package io.tarantool.driver.core;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Custom thread factory for scheduled executor service that creates daemon threads. Otherwise,
 * applications that neglect to close the client will not exit.
 *
 * 

This class is not part of the public API.

* * @author Sergey Volgin */ public class TarantoolDaemonThreadFactory implements ThreadFactory { private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1); private final AtomicInteger threadNumber = new AtomicInteger(1); private final String namePrefix; public TarantoolDaemonThreadFactory(String namePrefix) { this.namePrefix = namePrefix + "-" + POOL_NUMBER.incrementAndGet() + "-thread-"; } @Override public Thread newThread(final Runnable runnable) { Thread thread = new Thread(runnable, namePrefix + threadNumber.incrementAndGet()); thread.setDaemon(true); return thread; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy