How to correctly get thread name in Java?

前端 未结 4 1414
醉酒成梦
醉酒成梦 2021-02-03 23:38

I have this class for creating a thread in Java

package org.vdzundza.forms;

import java.awt.Graphics;
import java.awt.Graphics2D;

public class DrawThread exten         


        
4条回答
  •  耶瑟儿~
    2021-02-04 00:17

    There are two Objects involved, the DrawThread object that contains the run method, and the new Thread created using it as the Runnable.

    this.getName obtains the name of the unstarted DrawThread. The current thread is the one you started.

提交回复
热议问题