[concurrency-interest] PooledExector -- not clear on execute() + waitWhenBlocked()

Elias Ross eross@m-qube.com
13 Jan 2004 10:39:06 -0800


I've been trying to fix a bug in JBoss's JMS implementation.  I am
assuming during the Runnable.run() method an unchecked exception gets
thrown or the Thread.interrupt() is called and the pool eventually
becomes smaller and unusable.  Looking at the PooledExector class, it
isn't clear why this would be the case.  There are no obvious JavaDoc
statements that explain this sort of thing can happen.


Here is an example program.  Under 

import
EDU.oswego.cs.dl.util.concurrent.*;                                                                                                                                                               
public class PoolTest {
                                                                                                                                                               
  public class Task implements Runnable {
    public void run() {
      System.out.println("run");
      // throw new RuntimeException();
      Thread.currentThread().interrupt();
    }
  }

  public static void main(String args[]) {
    new PoolTest();
  }

  public PoolTest() {
    PooledExecutor pe = new PooledExecutor(3);
    pe.waitWhenBlocked();
    while (true) {
      try {
        pe.execute(new Task());
      } catch (Exception e) {
      }
    }
  }
}

[eross@dhcppc3 test]$ java -version
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build
Blackdown-1.4.1-01)
Java HotSpot(TM) Client VM (build Blackdown-1.4.1-01, mixed mode)

Release 1.3.2 of concurrent.jar