List of usage examples for org.springframework.scheduling.concurrent CustomizableThreadFactory setDaemon
public void setDaemon(boolean daemon)
From source file:org.geowebcache.georss.GeoRSSPoller.java
/** * Upon instantiation, spawns out a thread after #{@code startUpDelaySecs} seconds that * periodically (at least every each layer's {@link GeoRSSFeedDefinition#getPollInterval() poll * interval} polls the layers feed for change sets and if changes are found spawns a reseed * process on the tiles affected by the change set. * /*from w ww . j a v a 2s . c o m*/ * @param seeder * @param startUpDelaySecs * seconds to wait before start polling the layers */ public GeoRSSPoller(final TileBreeder seeder, final int startUpDelaySecs) { this.seeder = seeder; this.scheduledPolls = new ArrayList<PollDef>(); this.scheduledTasks = new ArrayList<GeoRSSPollTask>(); final int corePoolSize = 1; CustomizableThreadFactory tf = new CustomizableThreadFactory("GWC GeoRSS Poll Tasks-"); tf.setDaemon(true); tf.setThreadPriority(Thread.MIN_PRIORITY + 1); schedulingPollExecutorService = Executors.newScheduledThreadPool(corePoolSize, tf); schedulingPollExecutorService.submit(new Runnable() { public void run() { logger.info("Initializing GeoRSS poller in a background job..."); findEnabledPolls(); if (pollCount() > 0) { final TimeUnit seconds = TimeUnit.SECONDS; for (PollDef poll : scheduledPolls) { GeoRSSPollTask command = new GeoRSSPollTask(poll, seeder); GeoRSSFeedDefinition pollDef = poll.getPollDef(); long period = pollDef.getPollInterval(); logger.info("Scheduling layer " + poll.getLayer().getName() + " to poll the GeoRSS feed " + pollDef.getFeedUrl() + " every " + pollDef.getPollIntervalStr()); schedulingPollExecutorService.scheduleAtFixedRate(command, startUpDelaySecs, period, seconds); scheduledTasks.add(command); } logger.info("Will wait " + startUpDelaySecs + " seconds before launching the " + pollCount() + " GeoRSS polls found"); } else { logger.info("No enabled GeoRSS feeds found, poller will not run."); } } }); }
From source file:com.crossbusiness.resiliency.aspect.AbstractTimeoutAspect.java
private ThreadFactory threadFactory() { CustomizableThreadFactory tf = new CustomizableThreadFactory("sumo-timeout-"); tf.setThreadPriority(Thread.MAX_PRIORITY); tf.setDaemon(true); tf.setThreadGroupName("resiliency"); return tf;// w ww . j a va 2s. c om }
From source file:fr.xebia.springframework.concurrent.ThreadPoolExecutorFactory.java
@Override protected ThreadPoolExecutor createInstance() throws Exception { Assert.isTrue(this.corePoolSize >= 0, "corePoolSize must be greater than or equal to zero"); Assert.isTrue(this.maximumPoolSize > 0, "maximumPoolSize must be greater than zero"); Assert.isTrue(this.maximumPoolSize >= this.corePoolSize, "maximumPoolSize must be greater than or equal to corePoolSize"); Assert.isTrue(this.queueCapacity >= 0, "queueCapacity must be greater than or equal to zero"); CustomizableThreadFactory threadFactory = new CustomizableThreadFactory(this.beanName + "-"); threadFactory.setDaemon(true); BlockingQueue<Runnable> blockingQueue; if (queueCapacity == 0) { blockingQueue = new SynchronousQueue<Runnable>(); } else {/*from w ww. j a va 2 s .co m*/ blockingQueue = new LinkedBlockingQueue<Runnable>(queueCapacity); } ThreadPoolExecutor instance = new SpringJmxEnabledThreadPoolExecutor(corePoolSize, // maximumPoolSize, // keepAliveTimeInSeconds, // TimeUnit.SECONDS, // blockingQueue, // threadFactory, // rejectedExecutionHandlerClass.newInstance(), // new ObjectName("java.util.concurrent:type=ThreadPoolExecutor,name=" + beanName)); return instance; }
From source file:org.geowebcache.storage.blobstore.file.FileBlobStore.java
private void createDeleteExecutorService() { CustomizableThreadFactory tf;/*from www . j av a2s . c om*/ tf = new CustomizableThreadFactory("GWC FileStore delete directory thread-"); tf.setDaemon(true); tf.setThreadPriority(Thread.MIN_PRIORITY); deleteExecutorService = Executors.newFixedThreadPool(1); }
From source file:org.alfresco.bm.server.EventController.java
/** * Construct the controller/*from w w w . ja v a 2 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); }