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

org.tarantool.TarantoolThreadDaemonFactory Maven / Gradle / Ivy

There is a newer version: 1.9.4
Show newest version
package org.tarantool;

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

public class TarantoolThreadDaemonFactory implements ThreadFactory {

    private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1);
    private final AtomicInteger threadNumber = new AtomicInteger(1);
    private final String namePrefix;

    public TarantoolThreadDaemonFactory(String namePrefix) {
        this.namePrefix = namePrefix + "-" + POOL_NUMBER.incrementAndGet() + "-thread-";
    }

    @Override
    public Thread newThread(Runnable runnable) {
        Thread thread = new Thread(runnable, namePrefix + threadNumber.incrementAndGet());
        thread.setDaemon(true);

        return thread;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy