Why the out put of below code is Thread[main,5,main]

后端 未结 3 1360
迷失自我
迷失自我 2021-01-17 08:54
public class test1 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Thread t = Thread.currentThread();
        Syste         


        
3条回答
  •  有刺的猬
    2021-01-17 09:14

    Because of:

    /**
     * Returns a string representation of this thread, including the
     * thread's name, priority, and thread group.
     *
     * @return  a string representation of this thread.
     */
    public String toString() {
        ThreadGroup group = getThreadGroup();
        if (group != null) {
            return "Thread[" + getName() + "," + getPriority() + "," +
                           group.getName() + "]";
        } else {
            return "Thread[" + getName() + "," + getPriority() + "," +
                            "" + "]";
        }
    }
    

提交回复
热议问题