Does the Java thread have its own process identifier?

I want to get the thread process id to find out how much memory it takes.

+5
source share
4 answers

It depends a lot on the OS and how it manages the threads. Theoretically, it also depends on how the JVM implements threads, but all modern JVMs implement them as native threads.

On Linux, each thread will be used to get its own process identifier, but most tools hide everything but one thread for each process (i.e., you usually don't see them unless you explicitly request them, psuse a flag -m, for example). This is because the Linux kernel does not really matter much between threads and tasks.

Edit: since I just found out that this is no longer necessary: ​​you can create a stream with the same PID as the parent, in which case the streams will have different stream identifiers.

, , , , ( , shown_memory_use, shown_memory_user * number_of_threads).

+10

PID, . , , . PID Java- ( , ManagementFactory.getRuntimeMXBean().getName(), , PID).

+4

, PID . , PID. , ?

+3

, . , . , , .

, , . , . ( )

, . , 24 1 . 96 £ 2K. , , , .

+1
source

All Articles