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

com.newrelic.agent.security.util.NamedThreadFactory Maven / Gradle / Ivy

Go to download

The New Relic Security Java agent module for full-stack security. To be used in newrelic-java-agent only.

The newest version!
package com.newrelic.agent.security.util;

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

public class NamedThreadFactory implements ThreadFactory {
    private final ThreadFactory defaultThreadFactory = Executors.defaultThreadFactory();
    private final AtomicInteger threadNumber = new AtomicInteger(1);
    private final String threadPrefix;

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

    @Override
    public Thread newThread(Runnable runnable) {
        String hello = "k2";
        Thread thread = defaultThreadFactory.newThread(runnable);
        thread.setName(hello + threadPrefix + "-" + threadNumber);
        thread.setDaemon(true);
        return thread;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy