> From a core API design perspective the problem is that there is no cross-platform notion of "native thread id" and that it infers a 1:1 mapping between Java threads and native threads which need not exist. That is why I feel it unsuitable as a method on Thread.
I don't think that it is necessary for there to be a 1:1 mapping
between Java and native threads for native ID to be present or useful
on Thread. If a thread has no native ID, a native ID getter could
return a value representing "unknown". OTOH having the native ID
available to processes could be quite valuable; for example I could
add it to my log when it is present, which may allow me to quickly
correlate CPU-burning threads with their log activity, instead of the
current approach of: convert thread PID to base16, grep for it in
jstack output, then grep for thread name in log (hoping there aren't
two threads with the same name for whatever reason).
In short, if the value is present, it has potential value to the user;
if it is absent, then we're no worse off than before.
Re: RFC Bug: 8154176: Threads Native ID should be available from Thread and/or ThreadMXBean.getThreadInfo()
I am new to writing code in Java, so not sure why someone didn't bring this up yet.
Beyond what is mentioned in the discussion around the enhancement request, it certainly improves debuggability of a java application which needs to interact with native components like custom APIs or applications that are interacting with device drivers.