What is NLWP on Solaris?

From EggeWiki

If one does a prstat on Solaris (top), one will see the column NLWP.

   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP       
 19185 fruity   1348M  661M sleep   59    0   0:26:59 0.3% java/107
 13286 fruity   3558M  833M sleep   59    0   0:03:25 0.2% java/191
  2999 fruity   1501M  905M sleep   59    0   0:47:40 0.2% java/223

Often this column is confusing. What is means, is Number of Lightweight Processes. This basically amounts to the number of threads a program has running.

In the Unix world, there is not a huge difference between a process and a thread. The main difference is processes don't share memory by default, and threads do. On Windows, there is a larger distinction, and process are much 'heavier' than threads. It's for this reason, many of the services in Windows run in the process as different threads. One can see the svchost processes on Windows running multiple threads, and which may supporting one or more services.

For the Java Program, the NLWP is the number of threads you have going. On the older version of the linux kernel didn't support 'threads' at all. A thin layer called LinuxThreads attempted to emulate thread behavior by having a collection of processes share memory. Java was able to run, as collection of processes which shared the same memory space. This created problems with signaling, and one had to be careful to signal the parent process. One could literally kill running threads in a Java process by issuing a kill command. Additional this was a bit odd when one would do a ps as see 40 processes, but it really shows how little difference there is between threads and processes on Unix. Fortunately, later versions of Linux got a proper thread library which behaves similar to the one found on Solaris.