List of usage examples for org.springframework.scheduling.concurrent CustomizableThreadFactory setThreadGroup
public void setThreadGroup(@Nullable ThreadGroup threadGroup)
From source file:org.alfresco.bm.server.EventController.java
/** * Construct the controller// w w w. j a v a2 s .c o m * * @param driverId the ID of the driver controlling the events * @param testRunFqn the fully qualified name of the test run * @param testDAO the test DAO for accessing low level data * @param testRunId the ID of the test run being controlled * @param eventService the source of events that will be pushed for execution * @param eventProducers the registry of producers of events * @param eventProcessors the registry of processors for events * @param resultService the service used to store and retrieve event results * @param sessionService the service to carry session IDs between events * @param logService the service to record log messages for the end user * @param threadCount the number of threads available to the processor */ public EventController(String driverId, String testRunFqn, EventService eventService, EventProducerRegistry eventProducers, EventProcessorRegistry eventProcessors, ResultService resultService, SessionService sessionService, TestRunLogService logService, int threadCount) { thread = new Thread(new ThreadGroup(testRunFqn), this, testRunFqn + "-Controller"); thread.setDaemon(false); // Requires explicit shutdown this.driverId = driverId; this.testRunFqn = testRunFqn; this.eventService = eventService; this.eventProducers = eventProducers; this.eventProcessors = eventProcessors; this.resultService = resultService; this.sessionService = sessionService; this.logService = logService; this.threadCount = threadCount; // Configure threads CustomizableThreadFactory threadFactory = new CustomizableThreadFactory(testRunFqn + "-"); threadFactory.setThreadGroup(thread.getThreadGroup()); threadFactory.setDaemon(true); // Configure work queue SynchronousQueue<Runnable> queue = new SynchronousQueue<Runnable>(true); // Configure executor RejectedExecutionHandler abortPolicy = new ThreadPoolExecutor.CallerRunsPolicy(); executor = new ThreadPoolExecutor(threadCount, threadCount, 60, TimeUnit.SECONDS, queue, threadFactory, abortPolicy); setRunning(true); }