com.amazonaws.services.sqs.util.DaemonThreadFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of amazon-sqs-java-temporary-queues-client Show documentation
Show all versions of amazon-sqs-java-temporary-queues-client Show documentation
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;
}
}