标签:exce exe str print tst code 阻塞 stat 疑难杂症
代码如下
package com.learn.concurrent.probolem; import java.util.Date; import java.util.concurrent.CountDownLatch; /** * @author wx * @Description * @date 2019/05/12 18:33 */ public class DateProblem { public static void main(String[] args) { new DateProblem().execute(); } public void execute() { CountDownLatch latch = new CountDownLatch(1); new Thread(new Worker(latch)).start(); try { latch.await(); System.out.println("work has been done"); } catch (InterruptedException e) { e.printStackTrace(); } } class Worker implements Runnable { private CountDownLatch latch; public Worker(CountDownLatch latch) { this.latch = latch; } @Override public void run() { System.out.println("point 1"); System.out.println("point 2"+new Date()); latch.countDown(); } } }
在上面红色代码出设置一个断点,发现只有"Point 1"这条消息输出了,"Point 2" 这条消息没有输出
标签:exce exe str print tst code 阻塞 stat 疑难杂症
原文地址:https://www.cnblogs.com/heben/p/10853677.html