JDK-8179011 : Can not display thread name in Linux top command column
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: generic
  • Submitted: 2017-04-20
  • Updated: 2017-04-20
  • Resolved: 2017-04-20
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Red Hat Enterprise Linux Server release 6.6 (Santiago)

A DESCRIPTION OF THE PROBLEM :
Jdk 1.8 can not display any thread name in Red Hat Enterprise Linux Server release 6.6.

REGRESSION.  Last worked in version 6u45

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Step1:Compile program
  javac Test.java
Step2: Run program
  java Test
Step3: Find process id
  ps -ef|grep java
Step4:Display process thread detail
 top -Hp <process id from step 3>


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In top command screen shows thread name "name for test" in  "COMMAND" column
ACTUAL -
In top command screen shows thread name "java" in  "COMMAND" column.
Any thread name is lost

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Test.java

public class Test
{
        public static void main(String [] argv)
        {
                new Thread("name for test"){
                        public void run()
                        {
                                while(true){
                                try
                                {
                                        for(int i = 0; i < 10000000; i ++);
                                        Thread.sleep(1000);
                                }
                                catch(Exception e)
                                {
                                }
                                }
                        }
                }.start();
        }
}
---------- END SOURCE ----------


Comments
If I recall the history correctly the setting of the native thread name was introduced on mac OS X only in 7u4, and hence is also available there in 8 and 9. For 9 we expanded this to linux and windows. There is no support for this in any JDK 6 release.
20-04-2017

Java thread name usaually will not be passed to native threads. Using tools like top won't show them. With RFE JDK-7102541 now it will be taken care in 9. Please see the output from 9 ea b165 == top -Hp 3342 Threads: 35 total, 0 running, 35 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.1 us, 0.0 sy, 0.0 ni, 99.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 29873116 total, 5989632 free, 769244 used, 23114240 buff/cache KiB Swap: 14335984 total, 14335984 free, 0 used. 28750548 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3342 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 java 3351 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.14 java 3352 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 GC Thread#0 3353 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 GC Thread#1 3354 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 GC Thread#2 3355 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 GC Thread#3 3356 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 GC Thread#4 3357 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 GC Thread#5 3358 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 GC Thread#6 3359 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 GC Thread#7 3360 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Refine#7 3361 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Refine#6 3362 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Refine#5 3363 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Refine#4 3364 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Refine#3 3365 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Refine#2 3366 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Refine#1 3367 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Refine#0 3368 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Young RemSet 3369 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Main Marker 3370 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Marker#0 3371 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 G1 Marker#1 3372 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 VM Thread 3373 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 Reference Handl 3374 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 Finalizer 3375 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 Signal Dispatch 3376 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.01 C2 CompilerThre 3377 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 C2 CompilerThre 3378 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 C2 CompilerThre 3379 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.04 C1 CompilerThre 3380 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 Sweeper thread 3381 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 Common-Cleaner 3382 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 Service Thread 3383 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 VM Periodic Tas 3384 fmatte 20 0 11.178g 29576 12276 S 0.0 0.1 0:00.00 name for test
20-04-2017

Verified this is not a regression, removing regression label
20-04-2017