JDK-8365974 : Thread startup is slow when a large number of threads exit
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17,21,26
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2025-08-22
  • Updated: 2025-08-25
  • Resolved: 2025-08-25
Related Reports
Duplicate :  
Description
Thread startup is slow when a large number of threads exit.Sometimes thread startup takes more than 30 seconds on my machine. Async-profiler shows the most time is spent in ThreadsSMRSupport::smr_delete.


```
public class ThreadStartTest {
    private static Thread[] threads = new Thread[30000];
    private static volatile boolean done = false;

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

    private static void test() {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    for (int i = 0; i < threads.length; i++) {
                        Thread myThread = new Thread(new MyThread());
                        myThread.setDaemon(true);
                        threads[i] = myThread;
                    }

                    for (int i = 0; i < threads.length; i++) {
                        long start = System.nanoTime();
                        threads[i].start();
                        long end = System.nanoTime();
                        long time = end - start;
                        if (time > 10_000_000) {
                            System.out.println(threads[i].getName() + " took " + time + " nanoseconds");
                        }
                    }
                    done = true;
                    try {
                        Thread.sleep(100L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    done = false;
                }
            }
        });
        thread.setName("Producer Thread");
        thread.start();
    }

    private static class MyThread implements Runnable {
        @Override
        public void run() {
            while (!done) {
                try {
                    Thread.sleep(100L);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}

```


Comments
JDK-8307970 will look at all aspects of the slow downs being seen. Re-closing as a duplicate.
25-08-2025

Async-profiler shows the most time is spent in ThreadsSMRSupport::smr_delete, not like JDK-8307970.
25-08-2025

This is the same concern reported in JDK-8307970. Closing as a duplicate.
24-08-2025