官方jdk文档在如下指出了实现线程有两种方式:
class RunnableStyle implements Runnable{
public static void main(String[] args) {
Thread thread = new Thread(new RunnableStyle());
thread.start();
}
@Override
public void run() {
System.out.println("用runnable方式实现线程");
}
}
class ThreadStyle extends Thread {
public static void main(String[] args) {
Thread thread = new ThreadStyle();
thread.start();
}
@Override
public void run() {
System.out.println("用runnable方式实现线程");
}
}
原文:https://www.cnblogs.com/allinone/p/13726275.html