5

I have a Clojure app that I am developing. I am testing it on the server, mostly by going into a "screen" session and typing:

java -jar lo_login_service-0.2-standalone.jar

and then I kill it by hitting Control-C. Then I make some changes. Then I test it again.

I assume only 1 PID is in use. If I do:

ps aux

I only see 1 PID in use:

das      15028  0.2 22.1 1185300 133520 pts/5  Sl+  Jul26   3:19 java -jar lo_login_service-0.2-standalone.jar

But if I run "htop", then I see:

15029 das        20   0 1157M  130M  9960 S  0.0 22.2  0:25.85 java -jar lo_login_service-0.2-standalone.jar

15030 das        20   0 1157M  130M  9960 S  0.0 22.2  0:07.29 java -jar lo_login_service-0.2-standalone.jar

15031 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.02 java -jar lo_login_service-0.2-standalone.jar

15032 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.25 java -jar lo_login_service-0.2-standalone.jar

15033 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.00 java -jar lo_login_service-0.2-standalone.jar

15034 das        20   0 1157M  130M  9960 S  0.0 22.2  0:14.68 java -jar lo_login_service-0.2-standalone.jar

15035 das        20   0 1157M  130M  9960 S  0.0 22.2  0:11.46 java -jar lo_login_service-0.2-standalone.jar

15036 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.00 java -jar lo_login_service-0.2-standalone.jar

15038 das        20   0 1157M  130M  9960 S  0.0 22.2  0:08.46 java -jar lo_login_service-0.2-standalone.jar

15039 das        20   0 1157M  130M  9960 S  0.0 22.2  0:04.50 java -jar lo_login_service-0.2-standalone.jar

15040 das        20   0 1157M  130M  9960 S  0.0 22.2  0:14.81 java -jar lo_login_service-0.2-standalone.jar

15041 das        20   0 1157M  130M  9960 S  0.0 22.2  0:03.93 java -jar lo_login_service-0.2-standalone.jar

15042 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.09 java -jar lo_login_service-0.2-standalone.jar

15043 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.00 java -jar lo_login_service-0.2-standalone.jar

15044 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.00 java -jar lo_login_service-0.2-standalone.jar

15045 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.00 java -jar lo_login_service-0.2-standalone.jar

15046 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.00 java -jar lo_login_service-0.2-standalone.jar

15047 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.00 java -jar lo_login_service-0.2-standalone.jar

15048 das        20   0 1157M  130M  9960 S  0.0 22.2  0:00.00 java -jar lo_login_service-0.2-standalone.jar

Why does htop show me so many PIDs in use?

cerhovice
  • 676
  • 1
  • 10
  • 24

1 Answers1

5

Those probably are the threads used by your application. To only display the process you can press F2 (Setup) > Display options > Hide userland threads > F10 (Save).

You can see here an example with hidden/shown user threads (they are shown here as a tree because the option Tree view from the same menu is enabled):

enter image description here

EDIT: I forgot to mention that the numbers in the PID column are not PID's of the threads, but a kernel thread "ID" (not sure if this is the right term). Using the scenario of the image above as source, you would find them in /proc/2321/tasks:

$ ls /proc/2321/task      
2321  2323  2325  2326  2327
Salem
  • 12,808
  • 4
  • 34
  • 54
  • Thank you for that, but what are the numbers? 15029, 15031, etc. They look exactly like the PID. But threads don't have PIDs. – cerhovice Jul 27 '14 at 23:07
  • htop author here! @Salem's answer is correct. Threads have TIDs, which work just like PIDs. See `man 5 proc` for more info. – Hisham H M Jul 28 '14 at 17:44
  • @Salem - how would you map thread ID to your actual thread ? Is there a way that we can do it? – liv2hak May 10 '22 at 02:05