Index: src/test/java/org/jboss/ejb3/core/test/ejbthree1703/unit/ThreadLocalPoolStatsTestCase.java
===================================================================
--- src/test/java/org/jboss/ejb3/core/test/ejbthree1703/unit/ThreadLocalPoolStatsTestCase.java	(revision 106735)
+++ src/test/java/org/jboss/ejb3/core/test/ejbthree1703/unit/ThreadLocalPoolStatsTestCase.java	(revision )
@@ -21,15 +21,6 @@
  */
 package org.jboss.ejb3.core.test.ejbthree1703.unit;
 
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static junit.framework.Assert.assertEquals;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
 import org.jboss.ejb3.core.test.ejbthree1703.NoopBean;
@@ -40,7 +31,18 @@
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeoutException;
 
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static junit.framework.Assert.assertEquals;
+
+
 /**
  * (created - removed) = (inUse + available)
  * 
@@ -190,20 +192,49 @@
       Future<?> futures[] = new Future[2];
       futures[0] = service.submit(task);
       futures[1] = service.submit(task);
-      
+
+      try
+      {
-      entree.await(5, SECONDS);
-      
+         entree.await(5, SECONDS);
+
+         try
+         {
-      Pool pool = container.getPool();
-      assertEquals(2, pool.getCreateCount());
-      assertEquals("the pool should have grown", 2, pool.getMaxSize());
-      int inUse = pool.getMaxSize() - pool.getAvailableCount();
-      assertEquals("the instance should be in use", 2, inUse);
+            Pool pool = container.getPool();
+            assertEquals(2, pool.getCreateCount());
+            assertEquals("the pool should have grown", 2, pool.getMaxSize());
+            int inUse = pool.getMaxSize() - pool.getAvailableCount();
+            assertEquals("the instance should be in use", 2, inUse);
-      
+         }
+         finally
+         {
-      exit.await(5, SECONDS);
+            exit.await(5, SECONDS);
+         }
-      
-      futures[0].get(5, SECONDS);
-      futures[1].get(5, SECONDS);
+
+         futures[0].get(5, SECONDS);
+         futures[1].get(5, SECONDS);
+      }
+      catch(TimeoutException e)
+      {
+         // something bad must have happened
+         try
+         {
+            futures[0].get(5, SECONDS);
+         }
+         catch(ExecutionException ee)
+         {
+            ee.getCause().printStackTrace();
+         }
+         try
+         {
+            futures[1].get(5, SECONDS);
+         }
+         catch(ExecutionException ee)
+         {
+            ee.getCause().printStackTrace();
+         }
+         throw e;
+      }
-      
+
       service.shutdown();
 
    }
Index: src/main/java/org/jboss/ejb3/pool/AbstractPool.java
===================================================================
--- src/main/java/org/jboss/ejb3/pool/AbstractPool.java	(revision 106735)
+++ src/main/java/org/jboss/ejb3/pool/AbstractPool.java	(revision )
@@ -26,6 +26,8 @@
 import org.jboss.injection.Injector;
 import org.jboss.logging.Logger;
 
+import java.util.concurrent.atomic.AtomicInteger;
+
 /**
  * The base of all pool implementations.
  *
@@ -40,8 +42,8 @@
 
    protected Injector[] injectors;
    protected Container container;
-   protected int createCount = 0;
-   protected int removeCount = 0;
+   private AtomicInteger createCount = new AtomicInteger(0);
+   private AtomicInteger removeCount = new AtomicInteger(0);
 
    public AbstractPool()
    {
@@ -50,12 +52,12 @@
 
    public int getCreateCount()
    {
-      return createCount;
+      return createCount.get();
    }
 
    public int getRemoveCount()
    {
-      return removeCount;
+      return removeCount.get();
    }
 
    public void initialize(Container container, int maxSize, long timeout)
@@ -91,7 +93,7 @@
 
       // the init method only applies to stateful session beans
 
-      ++createCount;
+      createCount.incrementAndGet();
 
       return ctx;
    }
@@ -131,7 +133,7 @@
       finally
       {
          ctx.remove();
-         ++removeCount;
+         removeCount.incrementAndGet();
       }
    }
 }
Index: src/test/java/org/jboss/ejb3/core/test/ejbthree1703/NoopBean.java
===================================================================
--- src/test/java/org/jboss/ejb3/core/test/ejbthree1703/NoopBean.java	(revision 106735)
+++ src/test/java/org/jboss/ejb3/core/test/ejbthree1703/NoopBean.java	(revision )
@@ -21,18 +21,17 @@
  */
 package org.jboss.ejb3.core.test.ejbthree1703;
 
-import static java.util.concurrent.TimeUnit.SECONDS;
+import org.jboss.logging.Logger;
 
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
 import java.util.concurrent.BrokenBarrierException;
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.TimeoutException;
 
-import javax.annotation.Resource;
-import javax.ejb.SessionContext;
-import javax.ejb.Stateless;
+import static java.util.concurrent.TimeUnit.SECONDS;
 
-import org.jboss.logging.Logger;
-
 /**
  * @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
  * @version $Revision: $
@@ -63,7 +62,7 @@
 
    public void shoo(CyclicBarrier entree, CyclicBarrier exit)
    {
-      log.debug("entering barriers");
+      log.debug(Thread.currentThread() + ": entering barriers");
       try
       {
          entree.await(5, SECONDS);
Index: src/main/java/org/jboss/ejb3/InfinitePool.java
===================================================================
--- src/main/java/org/jboss/ejb3/InfinitePool.java	(revision 106735)
+++ src/main/java/org/jboss/ejb3/InfinitePool.java	(revision )
@@ -35,7 +35,12 @@
 public class InfinitePool extends AbstractPool
 {
    private List<BeanContext> active = new LinkedList<BeanContext>();
-   
+
+   /**
+    * Needs to be part of the sync block, because else other threads will miss it.
+    */
+   private int size;
+
    public void destroy()
    {
       for(BeanContext ctx : active)
@@ -44,6 +49,7 @@
          super.remove(ctx);
       }
       active = null;
+      size = 0;
    }
 
    public BeanContext<?> get()
@@ -57,6 +63,7 @@
       synchronized(active)
       {
          active.add(ctx);
+         size = active.size();
       }
       return ctx;
    }
@@ -68,7 +75,7 @@
 
    public int getCurrentSize()
    {
-      return active.size();
+      return size;
    }
 
    public int getMaxSize()
@@ -86,6 +93,7 @@
       synchronized(active)
       {
          active.remove(ctx);
+         size = active.size();
       }
       
       super.remove(ctx);
