As known
myTid() -
Returns the identifier of the calling thread, which be used with setThreadPriority(int, int).
But I found Thread.currentThread().getId()
does not equal to Process.myTid()
. So, my guess the former is a JVM edition thread id and the latter is Linux edition thread id.
Am I right? If so, why does java make its own thread id and not use Linux thread id?
UPDATE:
After further research and reading the source code of android, I have new realization:
Process.myTid()
is a platform(OS) related operation, and so does Process.setThreadPriority()
, in native level source of android, they all invoke a system call to realize the target.
But java is a platform independent language, java doesn't force the host os need a "tid" or a getTid()
method, since another os may identify its thread by a string key(just a example, :)). Then java identify its thread with its own way, assign a unique thread id in java scope, if java provide a static api like Process.setThreadPriority()
, then the java scope id definitely will be one parameter, but we needn't since we can do this by call a Thread object method setPriority(int priority)
.
Any comment is welcome.
Updated:
The answers all is right. But fadden's comment make me more clear. Thank you all.