title: Is there a limit on the maximum number of threadpools created during an application lifetime?
body: <p>Consider the following code:</p>
  <pre class="lang-java prettyprint-override"><code>class Test {
      public static void main(String... args) {
          var t = new Test();
          while(true) {
              t.work();
          }
      }
      public void work() {
          ExecutorService executorService = Executors.newFixedThreadPool(10);
  
          try {
               /* Do work */
          }
          finally {
              executorService.shutdown();
          }
      }
  }
  </code></pre>
  <p>Is there a limit on how many thread pools there can be in the lifetime of the app (not at the same time).</p>
  <p>I tried looking into source code and ran this test for some time, but seems like there is no limit. What's going to happen once the thread pool counter overflows?</p>