1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2013 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -126,7 +126,7 @@ public void setQueueCapacity(int queueCapacity) {
126
126
* <p>Default is "false", exposing the raw executor as bean reference.
127
127
* Switch this flag to "true" to strictly prevent clients from
128
128
* modifying the executor's configuration.
129
- * @see java.util.concurrent.Executors#unconfigurableScheduledExecutorService
129
+ * @see java.util.concurrent.Executors#unconfigurableExecutorService
130
130
*/
131
131
public void setExposeUnconfigurableExecutor (boolean exposeUnconfigurableExecutor ) {
132
132
this .exposeUnconfigurableExecutor = exposeUnconfigurableExecutor ;
@@ -137,9 +137,8 @@ protected ExecutorService initializeExecutor(
137
137
ThreadFactory threadFactory , RejectedExecutionHandler rejectedExecutionHandler ) {
138
138
139
139
BlockingQueue <Runnable > queue = createQueue (this .queueCapacity );
140
- ThreadPoolExecutor executor = new ThreadPoolExecutor (
141
- this .corePoolSize , this .maxPoolSize , this .keepAliveSeconds , TimeUnit .SECONDS ,
142
- queue , threadFactory , rejectedExecutionHandler );
140
+ ThreadPoolExecutor executor = createExecutor (this .corePoolSize , this .maxPoolSize ,
141
+ this .keepAliveSeconds , queue , threadFactory , rejectedExecutionHandler );
143
142
if (this .allowCoreThreadTimeOut ) {
144
143
executor .allowCoreThreadTimeOut (true );
145
144
}
@@ -151,6 +150,27 @@ protected ExecutorService initializeExecutor(
151
150
return executor ;
152
151
}
153
152
153
+ /**
154
+ * Create a new instance of {@link ThreadPoolExecutor} or a subclass thereof.
155
+ * <p>The default implementation creates a standard {@link ThreadPoolExecutor}.
156
+ * Can be overridden to provide custom {@link ThreadPoolExecutor} subclasses.
157
+ * @param corePoolSize the specified core pool size
158
+ * @param maxPoolSize the specified maximum pool size
159
+ * @param keepAliveSeconds the specified keep-alive time in seconds
160
+ * @param queue the BlockingQueue to use
161
+ * @param threadFactory the ThreadFactory to use
162
+ * @param rejectedExecutionHandler the RejectedExecutionHandler to use
163
+ * @return a new ThreadPoolExecutor instance
164
+ * @see #afterPropertiesSet()
165
+ */
166
+ protected ThreadPoolExecutor createExecutor (
167
+ int corePoolSize , int maxPoolSize , int keepAliveSeconds , BlockingQueue <Runnable > queue ,
168
+ ThreadFactory threadFactory , RejectedExecutionHandler rejectedExecutionHandler ) {
169
+
170
+ return new ThreadPoolExecutor (corePoolSize , maxPoolSize ,
171
+ keepAliveSeconds , TimeUnit .SECONDS , queue , threadFactory , rejectedExecutionHandler );
172
+ }
173
+
154
174
/**
155
175
* Create the BlockingQueue to use for the ThreadPoolExecutor.
156
176
* <p>A LinkedBlockingQueue instance will be created for a positive
0 commit comments