Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manage thread count with respect to available memory in Java

How to manage thread count with respect to available memory in Java. That means, I want to control the count of running threads, by coding, with respect to memory available in the server. Any types of suggestion, tips, tutorial, lib is welcome.

like image 350
anij Avatar asked Jun 29 '26 14:06

anij


1 Answers

Yes use executorService. In Java Concurrency in Practice it is actually recommended to set the thread count based on the number of processors. I think the formula was thread count = number of processors + one, but I may remember wrong...

like image 152
Kristjan Veskimäe Avatar answered Jul 02 '26 04:07

Kristjan Veskimäe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!