java休眠启动

public void progress() {
        Test key = new Test();
        synchronized (key) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        for(int i = 0;i < 10;i ++) {
                            Thread.sleep(1000);
                            System.out.println("========================"+i+"=========================");
                            if(i == 9) {
                                key.notify();
                            }
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
            try {
                System.out.println("开始等待");
                key.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("等待结束");
        renderJson();
    }
    class Test{
        
    }

你可能感兴趣的:(java,java)