[concurrency-interest] some questions with ThreadPoolExecutor

freish freish at 163.com
Wed Aug 15 09:26:19 EDT 2012

perhaps it is really a bug.  In jdk1.7,there is no such problem.And I find that ThreadPoolExecutor is rewriten in jdk1.7.

Another problem with jdk1.6 and previous is as below:

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
public class TestSetCorePoolSize {
    public static void main(String[] args) throws InterruptedException {
        final ThreadPoolExecutor pool = (ThreadPoolExecutor)Executors.newFixedThreadPool(5);
        //waiting for threads in pool started
        new Thread(){
            public void run() {
                try {
                } catch (InterruptedException e) {
                System.out.println("set corePoolSize:3");
        for(int i=0; i<30; i++) {
            System.out.println("poolSize:" + ((ThreadPoolExecutor)pool).getPoolSize());

after setCorePoolSize called, the pool size won't become 3. But in jdk1.7,it is 3.and this is a reasonable behavor.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120815/478ae55c/attachment.html>

More information about the Concurrency-interest mailing list