On Apr 20, 8:41 am, Sunny <leone0...@yahoo.com> wrote:
....
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
Sun VM, so, yup, one native Linux thread per Java thread. But they
are "hidden".
At one point if I'm not mistaken IBM had a very creative Java VM for
Linux where things were different. Then when "NPTL" (Native Posix
Thread Library") came along for kernel 2.4 (not all kernel 2.4 have
NPTL),
IBM dropped that very creative VM.
Anyway, Linux threads got faster and faster. From kernel 2.4 to 2.6
we
went from mutex to futex to "robust futex" (for, hey, basic futex were
actually buggy

but then they were 'robust' but weren't that fast
anymore (the 'f' in "futex" stands for fast) so now we have...
"robust lightweight futexes".
I'm not kidding
And processes (and especially processes creation) are hyper-efficient
under Linux: this is something Windows-centric programmer usually
have a hard-time understanding.
On a modern Linux box (i.e. a 2.4 with NPTL or later kernel) you
won't see at first all the processes corresponding to Java threads:
they are "hidden".
You can find them using the "-L" switch to the 'ps' command (as
shown by Lew), but also in /proc/{pid}, if you look carefully.
The PIDs for the various threads are hidden, yet they exist.
You've got to look in /proc/{pid}/task/ to find the number of all
the hidden PIDs.
For example :
[alex@saturne 6.7G ~/] # ps aux | grep java
alex 31103 1.9 7.2 541984 263172 pts/7 Sl+ Apr21 1:27 /home/
alex/jdk1.6.0/bin/java -Xms192m -Xmx256m -XX:MaxPermSize=99m -ea -
server -Dsun.awt.keepWorkingSetOnMinimize=true -Xbootclasspath/p:../
lib/boot.jar: com.intellij.idea.Main
PID TTY TIME CMD
31103 pts/7 00:01:27 java
[alex@saturne 6.7G ~/] $ ls /proc/31103/
attr cmdline cwd exe loginuid mem oom_adj root
smaps statm task
auxv cpuset environ fd maps mounts oom_score seccomp
stat status wchan
[alex@saturne 6.7G ~/] $ ls /proc/31103/task/
31103 31110 31113 31116 31120 31124 31128 31135 31154 31161
31165 31171 31174 31184
31108 31111 31114 31117 31121 31125 31129 31136 31157 31163
31169 31172 31175
31109 31112 31115 31118 31122 31126 31134 31137 31160 31164
31170 31173 31181
The following one is interesting: by looking into /proc/ you won't
find, say, 31108...
But you know it exists from looking into the main java process's /proc/
{pid}/task/ subdir.
[alex@saturne 6.7G ~/] $ ls /proc/31108/
attr cmdline cwd exe loginuid mem oom_adj root
smaps statm task
auxv cpuset environ fd maps mounts oom_score seccomp
stat status wchan
Alex