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

com.amazonaws.services.sqs.util.DaemonThreadFactory Maven / Gradle / Ivy

Go to download

An Amazon SQS client that supports creating lightweight, automatically-deleted temporary queues, for use in common messaging patterns such as Request/Response. See http://aws.amazon.com/sqs.

The newest version!
package com.amazonaws.services.sqs.util;

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

public class DaemonThreadFactory implements ThreadFactory {
    static AtomicInteger threadCount = new AtomicInteger(0);

    private final String factoryID;

    public DaemonThreadFactory(String factoryID) {
        this.factoryID = factoryID;
    }

    @Override
    public Thread newThread(Runnable r) {
        int threadNumber = threadCount.addAndGet(1);
        Thread thread = new Thread(r);
        thread.setDaemon(true);
        thread.setName(factoryID + "-Thread-" + threadNumber);
        return thread;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy