List of usage examples for java.util.concurrent ScheduledThreadPoolExecutor getContinueExistingPeriodicTasksAfterShutdownPolicy
public boolean getContinueExistingPeriodicTasksAfterShutdownPolicy()
From source file:org.elasticsearch.client.sniff.SnifferTests.java
public void testDefaultSchedulerThreadFactory() { DefaultScheduler defaultScheduler = new DefaultScheduler(); try {/*from w w w .jav a 2 s. c o m*/ 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(); } }