< prev index next >

src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java

Print this page
*** 42,10 ***
--- 42,11 ---
  import java.util.List;
  import java.util.concurrent.atomic.AtomicInteger;
  import java.util.concurrent.locks.AbstractQueuedSynchronizer;
  import java.util.concurrent.locks.Condition;
  import java.util.concurrent.locks.ReentrantLock;
+ import jdk.internal.vm.SharedThreadContainer;
  
  /**
   * An {@link ExecutorService} that executes each submitted task using
   * one of possibly several pooled threads, normally configured
   * using {@link Executors} factory methods.

*** 475,10 ***
--- 476,15 ---
      /**
       * Wait condition to support awaitTermination.
       */
      private final Condition termination = mainLock.newCondition();
  
+     /**
+      * The thread container for the worker threads.
+      */
+     private final SharedThreadContainer container;
+ 
      /**
       * Tracks largest attained pool size. Accessed only under
       * mainLock.
       */
      private int largestPoolSize;

*** 724,10 ***
--- 730,11 ---
                      try {
                          terminated();
                      } finally {
                          ctl.set(ctlOf(TERMINATED, 0));
                          termination.signalAll();
+                         container.close();
                      }
                      return;
                  }
              } finally {
                  mainLock.unlock();

*** 940,11 ***
                      }
                  } finally {
                      mainLock.unlock();
                  }
                  if (workerAdded) {
!                     t.start();
                      workerStarted = true;
                  }
              }
          } finally {
              if (! workerStarted)
--- 947,11 ---
                      }
                  } finally {
                      mainLock.unlock();
                  }
                  if (workerAdded) {
!                     container.start(t);
                      workerStarted = true;
                  }
              }
          } finally {
              if (! workerStarted)

*** 1307,10 ***
--- 1314,13 ---
          this.maximumPoolSize = maximumPoolSize;
          this.workQueue = workQueue;
          this.keepAliveTime = unit.toNanos(keepAliveTime);
          this.threadFactory = threadFactory;
          this.handler = handler;
+ 
+         String name = getClass().getName() + "@" + System.identityHashCode(this);
+         this.container = SharedThreadContainer.create(name);
      }
  
      /**
       * Executes the given task sometime in the future.  The task
       * may execute in a new thread or in an existing pooled thread.
< prev index next >