protected ExecutorService createDefaultExecutor() { ThreadPoolExecutor rc = new ThreadPoolExecutor(getDefaultCorePoolSize(), getMaxThreadPoolSize(), getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { String threadName = name + "-" + id.incrementAndGet(); Thread thread = new Thread(runnable, threadName); thread.setDaemon(daemon); thread.setPriority(priority); if (threadClassLoader != null) { thread.setContextClassLoader(threadClassLoader); } thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(final Thread t, final Throwable e) { LOG.error("Error in thread '{}'", t.getName(), e); } }); LOG.trace("Created thread[{}]: {}", threadName, thread); return thread; } }); if (rejectedTaskHandler != null) { rc.setRejectedExecutionHandler(rejectedTaskHandler); } else { rc.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); } return rc; }
protected ExecutorService createDefaultExecutor() { ThreadPoolExecutor rc = new ThreadPoolExecutor(getDefaultCorePoolSize(), getMaxThreadPoolSize(), getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { String threadName = name + "-" + id.incrementAndGet(); Thread thread = new Thread(runnable, threadName); thread.setDaemon(daemon); thread.setPriority(priority); if (threadClassLoader != null) { thread.setContextClassLoader(threadClassLoader); } thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(final Thread t, final Throwable e) { LOG.error("Error in thread '{}'", t.getName(), e); } }); LOG.trace("Created thread[{}]: {}", threadName, thread); return thread; } }); if (rejectedTaskHandler != null) { rc.setRejectedExecutionHandler(rejectedTaskHandler); } else { rc.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); } return rc; }
protected ExecutorService createDefaultExecutor() { ThreadPoolExecutor rc = new ThreadPoolExecutor(getDefaultCorePoolSize(), getMaxThreadPoolSize(), getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { String threadName = name + "-" + id.incrementAndGet(); Thread thread = new Thread(runnable, threadName); thread.setDaemon(daemon); thread.setPriority(priority); if (threadClassLoader != null) { thread.setContextClassLoader(threadClassLoader); } thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(final Thread t, final Throwable e) { LOG.error("Error in thread '{}'", t.getName(), e); } }); LOG.trace("Created thread[{}]: {}", threadName, thread); return thread; } }); if (rejectedTaskHandler != null) { rc.setRejectedExecutionHandler(rejectedTaskHandler); } else { rc.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); } return rc; }
protected ExecutorService createDefaultExecutor() { ThreadPoolExecutor rc = new ThreadPoolExecutor(getDefaultCorePoolSize(), getMaxThreadPoolSize(), getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { String threadName = name + "-" + id.incrementAndGet(); Thread thread = new Thread(runnable, threadName); thread.setDaemon(daemon); thread.setPriority(priority); if (threadClassLoader != null) { thread.setContextClassLoader(threadClassLoader); } thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(final Thread t, final Throwable e) { LOG.error("Error in thread '{}'", t.getName(), e); } }); LOG.trace("Created thread[{}]: {}", threadName, thread); return thread; } }); if (rejectedTaskHandler != null) { rc.setRejectedExecutionHandler(rejectedTaskHandler); } else { rc.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); } return rc; }