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

com.blade.kit.NamedThreadFactory Maven / Gradle / Ivy

There is a newer version: 2.0.15.RELEASE
Show newest version
package com.blade.kit;

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

public class NamedThreadFactory implements ThreadFactory {

    private final String prefix;
    private final LongAdder threadNumber = new LongAdder();

    public NamedThreadFactory(String prefix) {
        this.prefix = prefix;
    }

    @Override
    public Thread newThread(Runnable runnable) {
        threadNumber.add(1);
        return new Thread(runnable, prefix + "threadㄧ" + threadNumber.intValue());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy