package com.test;
public class MyThread implements Runnable {//extends Thread 实现Runnable 或继承Thread
@Override
public void run() {
System.out.println("runable run.......");
}
}
package com.test;
import java.util.*;
public class TestCls {
public static void main(String[] args) throws InterruptedException {
System.out.println("main");
Thread thread = Thread.currentThread();
System.out.println(thread.getName());
MyThread myThread = new MyThread();
Thread thread1 = new Thread(myThread);//实现需要
thread1.start();//继承直接调用start
new Thread(new Runnable() {//实现接口 匿名类
@Override
public void run() {
System.out.println("eeeeee111");
}
}).start();
new Thread(){
@Override
public void run() {
System.out.println(1111111111);
}
}.start();
}
}