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

余生长醉 提交于 2019-12-02 13:22:01

Because thread.toString() returns a string representation of this thread, including the thread's name, priority, and thread group.

Returns a string representation of this thread, including the thread's name, priority, and thread group.

Source: https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#toString()

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() + "," +
                        "" + "]";
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!