@Bean public AsyncTaskExecutor exec() { SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor(); simpleAsyncTaskExecutor.setThreadNamePrefix("exec-"); return simpleAsyncTaskExecutor; }
@Bean public AsyncTaskExecutor exec() { SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor(); simpleAsyncTaskExecutor.setThreadNamePrefix("exec-"); return simpleAsyncTaskExecutor; }
@Test public void verifyDifferentThread() throws Exception { SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); taskExecutor.setThreadNamePrefix("test-"); ExecutorChannel channel = new ExecutorChannel(taskExecutor); CountDownLatch latch = new CountDownLatch(1); TestHandler handler = new TestHandler(latch); channel.subscribe(handler); channel.send(new GenericMessage<String>("test")); latch.await(1000, TimeUnit.MILLISECONDS); assertEquals(0, latch.getCount()); assertNotNull(handler.thread); assertFalse(Thread.currentThread().equals(handler.thread)); assertEquals("test-1", handler.thread.getName()); }
private TaskExecutor createDefaultTaskExecutor() { // create thread-pool for starting contexts ThreadGroup threadGroup = new ThreadGroup("spring-osgi-extender[" + ObjectUtils.getIdentityHexString(this) + "]-threads"); threadGroup.setDaemon(false); SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); taskExecutor.setThreadGroup(threadGroup); taskExecutor.setThreadNamePrefix("SpringOsgiExtenderThread-"); isTaskExecutorManagedInternally = true; return taskExecutor; }