Is it safe to run more than 1K threads in Java?

I'm making a program that tries to get all the possible results Threads in the program generate more threads (slightly more than a thousand) I'm terrible at multithreading. I'm worried that thread generation won't stop I am using the eclipse ide with the terminate button, which will stop all running threads if there is no other way? Can the JVM handle this?

Solution

Yes Clicking the terminate button in eclipse to start the JVM will stop the JVM, which will stop all running threads (just like killing the JVM process)

As for running a thousand threads, I don't recommend it... It sounds like a very slow method (because each thread can only run ~ n / 1000 times on N CPU cores at most)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>