package com.lovecoding.day14.thread01;

import org.junit.Test;

public class Test01 {

    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("java");
                }
            }
        }).start();

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("c++");
                }
            }
        });
        t1.start();
    }

    //实现接口
    @Test
    public void fun02() throws InterruptedException {
        //创建 mythread
        MyThread02 myThread02 = new MyThread02();
        //new Thread
        new Thread(myThread02).start();

        //主线程
        for (int i = 0; i < 100; i++) {
            Thread.sleep(10);
            System.out.println("world");
        }
    }

    //继承父类
    @Test
    public void fun01(){
        //创建 mythread
        MyThread01 myThread01 = new MyThread01();
        //调用strat 方法 自动执行run
        myThread01.start();

        //主线程
        for (int i = 0; i < 100; i++) {
            System.out.print("黑");
            System.out.print("龙");
            System.out.print("江");
            System.out.print("省");
            System.out.println();
        }
    }

}
