继承Thread和Runable来实现多线程

public class _thread implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println("1");
        }
    }
    public static void main(String[] args) {
        _thread t = new _thread();
        new Thread(t).start();
        //run是先后执行
//        t.run();
        for (int i = 0; i < 2000; i++) {
            System.out.println("2");
        }}}
public class _thread extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println("1");
        }}
    public static void main(String[] args) {
        _thread t = new _thread();
        //start交替执行
        t.start();
        //run是先后执行
//        t.run();
        for (int i = 0; i < 2000; i++) {
            System.out.println("2");
        }}}