use of java.util.concurrent.ThreadFactory in project neo4j by neo4j.
the class DaemonThreadFactory method newThread.
@Override
public Thread newThread(Runnable r) {
ThreadFactory def = Executors.defaultThreadFactory();
Thread thread = def.newThread(r);
thread.setDaemon(true);
return thread;
}
use of java.util.concurrent.ThreadFactory in project pinpoint by naver.
the class StandbySpanStreamDataSendWorker method start.
public void start() {
final ThreadFactory threadFactory = new PinpointThreadFactory(this.getClass().getSimpleName(), true);
this.workerThread = threadFactory.newThread(this);
logger.info("start() started.");
if (!workerThread.isAlive()) {
this.isStarted = true;
this.workerThread.start();
logger.info("start() completed.");
} else {
logger.info("start() failed. caused:already started.", this.getClass().getSimpleName());
}
}
use of java.util.concurrent.ThreadFactory in project pinpoint by naver.
the class BufferedUdpDataSender method startScheduledFlush.
private Thread startScheduledFlush() {
final ThreadFactory threadFactory = new PinpointThreadFactory(SCHEDULED_FLUSH, true);
final Thread thread = threadFactory.newThread(new Runnable() {
@Override
public void run() {
final Thread currentThread = Thread.currentThread();
while (!currentThread.isInterrupted()) {
try {
chunkHeaderBufferedSerializer.flush();
} catch (TException e) {
logger.warn("Failed to flush. caused={}", e.getMessage(), e);
}
try {
TimeUnit.MILLISECONDS.sleep(1000);
} catch (InterruptedException ignored) {
currentThread.interrupt();
}
}
logger.info("stop ScheduledFlush {} - {}", currentThread.getName(), currentThread.getId());
}
});
logger.info("stop ScheduledFlush {} - {}", thread.getName(), thread.getId());
thread.start();
return thread;
}
use of java.util.concurrent.ThreadFactory in project jersey by jersey.
the class AbstractThreadPoolProvider method createThreadFactory.
private ThreadFactory createThreadFactory() {
final ThreadFactoryBuilder factoryBuilder = new ThreadFactoryBuilder().setNameFormat(name + "-%d").setUncaughtExceptionHandler(new JerseyProcessingUncaughtExceptionHandler());
final ThreadFactory backingThreadFactory = getBackingThreadFactory();
if (backingThreadFactory != null) {
factoryBuilder.setThreadFactory(backingThreadFactory);
}
return factoryBuilder.build();
}
use of java.util.concurrent.ThreadFactory in project dropwizard by dropwizard.
the class LifecycleEnvironmentTest method executorServiceThreadFactory.
@Test
public void executorServiceThreadFactory() throws ExecutionException, InterruptedException {
final String expectedName = "DropWizard ThreadFactory Test";
final String expectedNamePattern = expectedName + "-%d";
final ThreadFactory tfactory = (new ThreadFactoryBuilder()).setDaemon(false).setNameFormat(expectedNamePattern).build();
final ExecutorService executorService = environment.executorService("Dropwizard Service", tfactory).build();
final Future<Boolean> isFactoryInUse = executorService.submit(() -> Thread.currentThread().getName().startsWith(expectedName));
assertThat(isFactoryInUse.get()).isTrue();
}
Aggregations