Among Java developers, a prevailing assumption is that the number of native threads that can be created within the Java Virtual Machine (JVM) is linked to the stack size. To scrutinize this widespread notion, an experiment was conducted. The results revealed that stack size plays a less significant role in native thread creation than previously thought.
The Experiment
The experiment utilized the following Java program, which continuously creates threads and counts them using an AtomicInteger
.