Java Threads: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 14: Line 14:
==Java Threads and Linux Processes==
==Java Threads and Linux Processes==


On a Linux system, each JVM thread counts as a "process", in that it is subject to system-wide and user-wide process number limitations (see "[[Linux_Process_Management_Concepts#Maximum_Number_of_Processes_Allowed_on_the_System|maximum number of processes allowed on a system]]" and "[[]]"). When a JVM instance adjust its number of threads, the change is reflected by <tt>/proc/</tt> "[[processes]]" count.
On a Linux system, each JVM thread counts as a "process", in that it is subject to system-wide and user-wide process number limitations (see "[[Linux_Process_Management_Concepts#Maximum_Number_of_Processes_Allowed_on_the_System|maximum number of processes allowed on a system]]" and "[[Linux_Process_Management_Concepts#Maximum_Number_of_Processes_Available_to_a_Single_User|maximum number of processes available to a single user]]"). When a JVM instance adjust its number of threads, the change is reflected by <tt>/proc/stat</tt> "[[Linux_Process_Information#.2Fproc.2Fstat|processes]]" count.


For an example of what happens when the number of Linux processes allowed to an user is reached, see {{Internal|Max_User_Processes_and_Java_OutOfMemoryError_%22unable_to_create_new_native_thread%22|OutOfMemoryError "unable to create new native thread"}}
For an example of what happens when the number of Linux processes allowed to an user is reached, see {{Internal|Max_User_Processes_and_Java_OutOfMemoryError_%22unable_to_create_new_native_thread%22|OutOfMemoryError "unable to create new native thread"}}


A simple Java program that allows experimenting with threads: {{External|https://github.com/NovaOrdis/playground/tree/master/java/threads/multiple-threads-spinning}}
A simple Java program that allows experimenting with threads: {{External|https://github.com/NovaOrdis/playground/tree/master/java/threads/multiple-threads-spinning}}

Revision as of 02:02, 22 April 2017

Internal

Subjects

Concepts

Daemon Thread

Java Threads and Linux Processes

On a Linux system, each JVM thread counts as a "process", in that it is subject to system-wide and user-wide process number limitations (see "maximum number of processes allowed on a system" and "maximum number of processes available to a single user"). When a JVM instance adjust its number of threads, the change is reflected by /proc/stat "processes" count.

For an example of what happens when the number of Linux processes allowed to an user is reached, see

OutOfMemoryError "unable to create new native thread"

A simple Java program that allows experimenting with threads:

https://github.com/NovaOrdis/playground/tree/master/java/threads/multiple-threads-spinning