This content has been marked as final. Show 4 replies
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?
There is no option to get native thread id from JMX.
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.