Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6458339

ThreadPoolExecutor very slow to shut down for large poolSize

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P3
    • Resolution: Fixed
    • 6
    • 7
    • core-libs
    • b08
    • generic
    • generic
    • Not verified

    Description

      Shutting down a thread pool with 1000 idle threads takes on the order of 10 seconds.
      The time for shutdown to complete for sufficiently large pool sizes
      is quadratic in the pool size.

      import java.util.*;
      import java.util.concurrent.*;

      public class InterruptStorm {
          public static void main(String[] args) throws Throwable {
      final int n = Integer.parseInt(args[0]);
      final ThreadPoolExecutor pool
      = new ThreadPoolExecutor(n, n, 0L, TimeUnit.SECONDS,
      new LinkedBlockingQueue<Runnable>());
      pool.prestartAllCoreThreads();

      long t0 = System.nanoTime();
      pool.shutdown();
      pool.awaitTermination(1L, TimeUnit.HOURS);
      System.out.printf("%3f%n", ((double) (System.nanoTime() - t0)/
      (1000.0 * 1000.0 * 1000.0)));
          }
      }

      Attachments

        Issue Links

          Activity

            People

              martin Martin Buchholz
              martin Martin Buchholz
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: