继承Thread类
package com.myThread;
public class MyThread1 extends Thread{
@Override
public void run() {
super.run();
System.out.println("hello this is myThread");
}
}
package com.test;
import com.myThread.MyThread1;
public class MyTest1 {
public static void main(String[] args) {
MyThread1 thread1 = new MyThread1();
thread1.start();
System.out.println("main end");
}
}
打印结果
main end
hello this is myThread
实现Runnable接口
package com.myThread;
public class MyThread2 implements Runnable {
@Override
public void run() {
System.out.println(