(by mistake I originally posted this to Java Programming forum, my apologies for cross-posting)
I am trying to match the native and java threads in Hotspot VM - this is easy when I have the text of the VM thread dump, as for each thread the VM dumps both its Java id (tid=xxx) and native thread id (nid=xxx).
The Java thread id is available in the java.lang.management.ThreadInfo but there seems to be no way to get the nid for a Java thread - is there any way to do this from Java code?
There is no API to get native thread ID.
It's not always one-to-one mapping from Java thread to native thread and it depends on the threading model that the application is running on. I presume it's useful when you need to use the system/native tools to obtain diagnostic information about a thread.
How are you going to use the native thread ID for? What would you like to develop with the API to get the native thread ID? This would be useful to help us understand your requirement.
thanks for the quick reply.
Yes, the usecase is pretty much being able to transition from a JMX-based Java thread diagnostics deeper into native OS (and more extensive) diagnostics.
I understand that it is up to the VM to define the mapping (if any) between Java and native threads. Perhaps an optional API (that a VM may choose not to support - similar to isThreadContentionMonitoringSupported) that would provide the native id for a java thread if it exists, would be a good way to address this?
Welcome to the forum. Please don't post in threads that are long dead and don't hijack other threads. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
I'm locking this thread now.