I would guess linux uses pthreads, but you could browse the JVM
source to be sure. I would imagine you might find what you're
looking for in the native java.lang.Thread sources.
I'm inferring that task corresponds to thread, so if you make a
pthread call to get the thread id, that might be what you're looking
for.
The thread/task id might even be tucked away in a private member of a
platform-specific class (this is the case with 1.6+ for AWT window
handles).
On Oct 27, 2007, at 10:55 AM, Quartz wrote:
Hi,
On linux, under the jvm process of pid=xxxxx, threads usually gets
listed under
/proc/xxxx/tasks/*.
I am trying to get the 'yyyyy' number in the proc filesystem for
the current jvm thread, as in
/proc/self/task/yyyyy.
As you can see, the jvm pid is not even required since there is a
sym link /proc/self, but there
is no such thing for the task id.
So, I don't know enough about the linux programming to drill into
jni to pull this thread id. I
was wondering if anyone could tell/show me the thread struct or
union that describes the thread
and how to pull the task id with JNA.
I hope to build an api as simple as
public int LinuxThreadUtils.getProcessId(); //done: first field of
content of /proc/self/stat
public int LinuxThreadUtils.getCurrentThreadTaskId();//TODO
If at all possible, a bonus API would be to get the task id off the
current thread, as in
public int LinuxThreadUtils.getThreadTaskId(Thread t);//bonus
Thanks.