Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Code of topics
package threadTest;
public class Test extends Thread implements Runnable{
@Override
public void run() {
System.out.println("I can run!!");
}
public static void main(String[] args) {
//实现Runnable接口创建线程的方式
Thread t1=new Thread(new Test());
t1.start();
//继承Thread类创建线程的方式
Test t2=new Test();
t2.start();
}
}