List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor destroy
@Override public void destroy()
From source file:com.bt.aloha.batchtest.PerformanceBatchTest.java
private void restartSimpleSipStack(int numberSimpleSipThreads) { ThreadPoolTaskExecutor threadPoolTaskExecutor = (ThreadPoolTaskExecutor) applicationContext .getBean("taskExecutor"); threadPoolTaskExecutor.destroy(); threadPoolTaskExecutor.setCorePoolSize(numberSimpleSipThreads); threadPoolTaskExecutor.initialize(); }
From source file:org.springframework.batch.repeat.support.TaskExecutorRepeatTemplateBulkAsynchronousTests.java
@Test public void testThrottleLimitEarlyFinishThreadStarvation() throws Exception { early = 2;//from w w w .jav a 2 s . c o m ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); // Set the concurrency limit below the throttle limit for possible // starvation condition taskExecutor.setMaxPoolSize(20); taskExecutor.setCorePoolSize(10); taskExecutor.setQueueCapacity(0); // This is the most sensible setting, otherwise the bookkeeping in // ResultHolderResultQueue gets out of whack when tasks are aborted. taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); taskExecutor.afterPropertiesSet(); template.setTaskExecutor(taskExecutor); template.iterate(callback); int frequency = Collections.frequency(items, "null"); // System.err.println("Frequency: " + frequency); // System.err.println("Items: " + items); // Extra tasks will be submitted before the termination is detected assertEquals(total, items.size() - frequency); assertTrue(frequency <= throttleLimit + 1); taskExecutor.destroy(); }