223 |
|
* @since 1.5 |
224 |
|
* @author Doug Lea |
225 |
|
*/ |
226 |
< |
public class ThreadPoolExecutor implements ExecutorService { |
226 |
> |
public class ThreadPoolExecutor extends AbstractExecutorService { |
227 |
|
/** |
228 |
|
* Queue used for holding tasks and handing off to worker threads. |
229 |
|
*/ |
1030 |
|
try { |
1031 |
|
int extra = this.corePoolSize - corePoolSize; |
1032 |
|
this.corePoolSize = corePoolSize; |
1033 |
< |
if (extra < 0) { |
1034 |
< |
Runnable r; |
1035 |
< |
while (extra++ < 0 && poolSize < corePoolSize && |
1036 |
< |
(r = workQueue.poll()) != null) |
1037 |
< |
addThread(r).start(); |
1038 |
< |
} |
1039 |
< |
else if (extra > 0 && poolSize > corePoolSize) { |
1033 |
> |
if (extra < 0) { |
1034 |
> |
Runnable r; |
1035 |
> |
while (extra++ < 0 && poolSize < corePoolSize && |
1036 |
> |
(r = workQueue.poll()) != null) |
1037 |
> |
addThread(r).start(); |
1038 |
> |
} |
1039 |
> |
else if (extra > 0 && poolSize > corePoolSize) { |
1040 |
|
Iterator<Worker> it = workers.iterator(); |
1041 |
|
while (it.hasNext() && |
1042 |
|
extra-- > 0 && |