Thread类是JAVA线程的抽象,而Runable是逻辑或任务的一种抽象接口
示例:
package test;
public class NewThread {
private static class UseThread extends Thread {
public void run(){
super.run();
System.out.println("i am extendec thread");
}
}
private static class UseRunnable implements Runnable{
@Override
public void run() {
System.out.println("i am runnable");
}
}
public static void main(String[] args) {
UseThread ut =new UseThread();
ut.start();
UseRunnable ur =new UseRunnable();
new Thread(ur).start();
}
}