10 2018 档案

摘要:1 //使用newFixedThreadPool创建线程 2 ExecutorService fixedPool = Executors.newFixedThreadPool(5); 3 for (int i = 0; i <20; i++) { 4 fixedPool.execute(new MyThread03(... 阅读全文
posted @ 2018-10-09 18:01 卡多希 阅读(2262) 评论(0) 推荐(0)
摘要:1 public static void main(String[] args) { 2 //始终只有一个线程在执行 3 //使用newSingleThreadExecutor()创建静态线程池 4 ExecutorService SinglePool = Executors.newSingleThreadExecutor(); ... 阅读全文
posted @ 2018-10-09 17:57 卡多希 阅读(1673) 评论(0) 推荐(0)
摘要:1 /** 2 * 一共有两个人和两份资源, 3 * 一人手中有一份, 4 *但是,tang想得到对方的资源后,才后放手自己的资源(给对方享用), 5 *对方(dou)也是这样想的,两者都不让步, 6 */ 7 public class DeadIockThread { 8 9 /** 10 * 死锁 11 * @param args 1... 阅读全文
posted @ 2018-10-09 17:54 卡多希 阅读(112) 评论(0) 推荐(0)
摘要:ExecutorService pool = Executors.newCachedThreadPool();//使用newCachedThreadPool();创建静态线程池 for (int j = 1; j <= 10; j++) { pool.execute(new MyThread(j)); ... 阅读全文
posted @ 2018-10-09 15:39 卡多希 阅读(1080) 评论(0) 推荐(0)
摘要:1 /** 2 * 规律交换执行 3 * @author dell 4 * 5 */ 6 public class MyThread01 { 7 private static Object obj=new Object();//创建一个父类,父类有锁对象这个功能 8 9 public static void main(String[] args) th... 阅读全文
posted @ 2018-10-09 15:26 卡多希 阅读(175) 评论(0) 推荐(0)