阅读背景:

junit测试类测试多线程遇到的问题

来源:互联网 
    @Test
    public void testSychronized() throws InterruptedException {

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                /*System.out.println("I Hate U");
                synchronized (this){
                    System.out.println("I Love U");
                }*/
                while (true){
                    System.out.println("子线程");
                }
            }
        });
        t1.setDaemon(false);
        t1.start();
        Thread.sleep(2000);
        System.out.println("sss");
    }
    @Test
    public void testSychronized()



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: