The Java memory recycling mechanism will recycle threads that have finished executingrun. In this situation you encountered, it is probably that the threads were created too fast, causing most of the created threads to still be running
Use thread pool, same as @xixicat
The total number of threads that the system can create depends on the operating system, so in order to solve this exception, use the thread pool
Use java thread pool
The Java memory recycling mechanism will recycle threads that have finished executing
run
. In this situation you encountered, it is probably that the threads were created too fast, causing most of the created threads to still be runningUse thread pool, same as @xixicat
The total number of threads that the system can create depends on the operating system, so in order to solve this exception, use the thread pool