List of usage examples for java.util.concurrent ScheduledThreadPoolExecutor getThreadFactory
public ThreadFactory getThreadFactory()
From source file:org.elasticsearch.client.sniff.SnifferTests.java
public void testDefaultSchedulerThreadFactory() { DefaultScheduler defaultScheduler = new DefaultScheduler(); try {// w w w .j a v a 2s. c om ScheduledExecutorService executorService = defaultScheduler.executor; assertThat(executorService, instanceOf(ScheduledThreadPoolExecutor.class)); assertThat(executorService, instanceOf(ScheduledThreadPoolExecutor.class)); ScheduledThreadPoolExecutor executor = (ScheduledThreadPoolExecutor) executorService; assertTrue(executor.getRemoveOnCancelPolicy()); assertFalse(executor.getContinueExistingPeriodicTasksAfterShutdownPolicy()); assertTrue(executor.getExecuteExistingDelayedTasksAfterShutdownPolicy()); assertThat(executor.getThreadFactory(), instanceOf(Sniffer.SnifferThreadFactory.class)); int iters = randomIntBetween(3, 10); for (int i = 1; i <= iters; i++) { Thread thread = executor.getThreadFactory().newThread(new Runnable() { @Override public void run() { } }); assertThat(thread.getName(), equalTo("es_rest_client_sniffer[T#" + i + "]")); assertThat(thread.isDaemon(), is(true)); } } finally { defaultScheduler.shutdown(); } }