Are Java threads associated with a process on Linux?

I started the berth server and the ehcache instance, I soon encountered a flow restriction on linux when I started another jave process.

The error message was unable to create new native thread (PS My Linux OS is CentOS 6.2).

Then I used ps -xH to know that two java processes (jetty and ehcache) generate almost 800 threads, and the total number of ps -xH is 1023, ulimit -u is 1024.

So my question is, why does java spawn threads, but I ran into a process number limit?

PS I have enough memory

+4
source share
2 answers

Because for Linux Threads, the processes are basically the same. The difference between the two is that threads share things like memory, file descriptors, etc., but processes do not.

Check this one for a deeper understanding. Thus, threads and processes take into account your limit in 1023 processes.

You should probably try to create fewer threads that seem huge to me.

+3
source

This is certainly an excessive number of threads, at least for Jetty. Unless you have underlined your server with hundreds of requests per second, this should not happen. Double check that threads are not blocked indefinitely. In any case, configure the maximum number of threads allowed until the request is posted or rejected.

0
source

All Articles