代码块
package edu.xcdq.demo02;
public class Demo02 {
public static void main(String[] args) {
MyThread myThread=new MyThread();
Thread thread=new Thread(myThread);//把自定义类对象加入
thread.start();
}
}
测试块
package edu.xcdq.demo02;
public class MyThread implements Runnable {
@Override
public void run(){
System.out.println("接口中复写的run方法,是一个新线程");
System.out.println("当前线程名字"+Thread.currentThread());
}
}