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?