随笔分类 -  Thread

摘要:package Thread1; /** * 主方法 * * @author zhangyugeng * 创建汽车类Car 创建汽车工厂类CarFactory 创建顾客类Client */ public class CreateAndBuyCar { public static void main(String[] args) { Car car = ... 阅读全文
posted @ 2017-11-21 22:44 zhangyugeng 阅读(189) 评论(0) 推荐(0)
摘要:import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.TimeUnit; public class ThreadDemo5 { pub 阅读全文
posted @ 2017-11-18 21:59 zhangyugeng 阅读(102) 评论(0) 推荐(0)
摘要:public class ThreadDemo4 { static ShareData data=new ShareData(); public static void main(String[] args) { new Thread(new Myrunnable1(data)).start(); 阅读全文
posted @ 2017-11-18 19:25 zhangyugeng 阅读(215) 评论(0) 推荐(0)
摘要:import java.util.Random; public class ThreadDemo3 { public static void main(String[] args) { for(int i=0;i<2;i++){ //两个线程 new Thread(new Runnable() { 阅读全文
posted @ 2017-11-18 17:00 zhangyugeng 阅读(326) 评论(0) 推荐(0)
摘要:import java.util.HashMap;import java.util.Map;import java.util.Random; public class ThreadDemo2 { static int data = 0; //定义一个数据 static Map<Thread, Int 阅读全文
posted @ 2017-11-18 00:06 zhangyugeng 阅读(262) 评论(0) 推荐(0)
摘要:A thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurren 阅读全文
posted @ 2017-11-14 19:22 zhangyugeng 阅读(141) 评论(0) 推荐(0)