package com.xqx.test;

import java.util.concurrent.CountDownLatch;
/***
 * 测试线程取消--2
 * @author ruihu
 *
 */
public class ExportTest {
	
	public static void main(String[] args) {
		
		CountDownLatch lock = new CountDownLatch(1);//创建锁
		//1、执行
		ExportRunnable runnable = new ExportRunnable(lock);
		Thread thread = new Thread(runnable);
		thread.start();
		try {
			
			System.out.println("等待中。。。");
			lock.await();//阻塞等待执行完毕后执行
			System.out.println("执行完毕。。");
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		//2、继续执行后面代码
		if(!runnable.isFinished()){
			System.out.println("没有取消,继续执行后续操作");
		}else{
			System.out.print("已取消,返回警告");
		}
		
		//取消当前线程
		runnable.setCanceled(true);
		
		
	}

}
最近下载更多
cc900118  LV17 2021年9月17日
lironggang  LV38 2019年7月3日
1792312911  LV17 2018年6月26日
15735184511  LV7 2018年1月4日
你高冷  LV12 2017年10月12日
248196826  LV13 2016年11月26日
好脑壳  LV16 2016年11月9日
xuexizhuanyong23  LV16 2016年9月4日
最近浏览更多
爱情戴罪的羔羊  LV7 4月2日
微信网友_15002431817 2023年1月17日
暂无贡献等级
heqian  LV16 2023年1月10日
crosa_Don  LV18 2022年7月19日
2469095052  LV8 2022年5月27日
mylzdy  LV12 2022年5月12日
szf123  LV12 2022年4月22日
随便取个名字_哈哈  LV27 2021年11月7日
cc900118  LV17 2021年9月17日
vae222  LV2 2021年5月3日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友