2

I've been running tests were the size of a Java FixedThreadPool is modified as a variable. From researching the FixedThreadPool it seems you should be able to have as many threads in the pool as your memory will allow.

My i7 4-core machine easily handles over 4000 "normal" threads, but changing the threadpool size above 1024 deadlocks my tests. The same 1024 threadpool deadlock happens for an M1 macbook and 2-core macbook air. Is there a set max for a the ThreadPool? For sizes until then everything works fine for all machines.

1 Answer 1

2

The limit does not resides in jvm memory but in OS per user thread (process) limit. In linux or Mac OS you can check by ulimit -u. here you can find more info Maximum number of threads per process in Linux?

When you create ThreadPoolExecutor with Executors.newFixedThreadPool( nb ) no Thread is create and only a small amount of memory is require for each thread (perhaps zero if the implementation use a LinkedList or a map to keep the Worker (Thread))

other useful info here Maximum number of threads in a JVM?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.