@Override public ScheduledThreadPoolExecutor createScheduledRetriesPool(final String threadPrefix) { return new ScheduledThreadPoolExecutor(1, new NamedThreadFactory(threadPrefix + "_retries", Thread.currentThread().getContextClassLoader())); }
public Thread newThread(Runnable runnable) { Thread t = new Thread(runnable); configureThread(t); return t; }
protected void configureThread(Thread t) { if (contextClassLoader != null) { t.setContextClassLoader(contextClassLoader); } doConfigureThread(t); }
protected ScheduledExecutorService createScheduler() { ThreadFactory threadFactory = new NamedThreadFactory(this.getName() + ".scheduler"); ScheduledThreadPoolExecutor newExecutor = new ScheduledThreadPoolExecutor(4, threadFactory); newExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); newExecutor.setKeepAliveTime(this.getReceiverThreadingProfile().getThreadTTL(), TimeUnit.MILLISECONDS); newExecutor.allowCoreThreadTimeOut(true); return newExecutor; }
protected void configureThreadFactory(String name, ThreadingProfile tp, ThreadPoolExecutor pool) { // use a custom ThreadFactory if one has been configured if (tp.getThreadFactory() != null) { pool.setThreadFactory(tp.getThreadFactory()); } else { // ..else create a "NamedThreadFactory" if a proper name was passed in if (StringUtils.isNotBlank(name)) { // Threads must use the MuleApplicationClassLoader related to MuleContext or the // thread context class loader in case of embedding mule. pool.setThreadFactory(new NamedThreadFactory(name, Thread.currentThread().getContextClassLoader())); } else { // let ThreadPoolExecutor create a default ThreadFactory; // see Executors.defaultThreadFactory() } } }
idleTimeoutExecutorService = Executors.newCachedThreadPool(new NamedThreadFactory(threadNamePrefix + IDLE_TIMEOUT_THREADS_PREFIX_NAME)); idleTimeoutDelayedExecutor = new DelayedExecutor(idleTimeoutExecutorService);