How to correctly get thread name in Java?

前端 未结 4 1391
醉酒成梦
醉酒成梦 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:24

    simple call:

    new DrawThread().start();
    

    to start new Thread

    DrawThread drawThread;              // declare object of class DrawThread 
    drawThread = new DrawThread();      // instantiate object of class DrawThread
    drawThread.start();                 // call start to start DrawThread
    

    (DrawThread is extending Thread class) so involves:

      public synchronized void start() {
            checkNotStarted();
    
            hasBeenStarted = true;
    
            nativeCreate(this, stackSize, daemon);   // here Thread is created 
      }
    

    u call is ike PUT THREAD INSIDE THREAD (AS RUNNABLE) by calling:

    public Thread(Runnable runnable) {
        create(null, runnable, null, 0);
    }
    

提交回复
热议问题