标签 thread 下的文章

实现Runnable接口

public class FirstThread implements Runnable {

    @Override
    public void run() {
        System.out.println("first thread run...");
    }
}

new Thread(new FirstThread().start())

继承Thread类

Thread类本身就是实现的Runnable接口: Thread implements Runnable

public class SecondThread extends Thread {

    @Override
    public void run() {
        System.out.println("second thread run...");
    }
}
new Thread(new SecondThread().start())

实现Callable接口来创建Thread线程

- 阅读剩余部分 -