package com.lovecoding.day14.ex01;

public class Test01 {

    public static void main(String[] args) {

        ChatThread chatThread = new ChatThread();

        new Thread(new Runnable() {
            @Override
            public void run() {
                //打印[1,10]，每隔10毫秒打印一个数字，现在当主线程打印完5之后，就让自定义线程类加塞，直到自定义线程类结束，主线程再继续。
                for (int i = 0; i < 10; i++) {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    if ( i == 5 ){
                        // 插入
                        chatThread.start();
                        try {
                            chatThread.join();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    System.out.println(i+"--"+Thread.currentThread().getName());
                }
            }
        }).start();



    }

}
