摘要: public class test { private static final int THREAD_COUNT_NUM = 7; private static CountDownLatch latch = new CountDownLatch(THREAD_COUNT_NUM); public 阅读全文
posted @ 2019-03-27 20:51 卡多希 阅读(101) 评论(0) 推荐(0)
摘要: public class test02 { public static void tt(int num){ if (num<10){//小于10不输出 System.out.print(num); }else { int re = num%10;//取传进来的值的余赋值给re输出 System.ou 阅读全文
posted @ 2019-03-27 20:48 卡多希 阅读(166) 评论(0) 推荐(0)
摘要: 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)
摘要: flag = false时;while(!flag) 时进入循环。当count<=0时,flag的值为true; while(!flag) 时不进循环,return,结束执行 阅读全文
posted @ 2018-09-25 13:52 卡多希 阅读(133) 评论(0) 推荐(0)
摘要: import java.util.Scanner; public class Test08 { Student08[] student=new Student08[5];//创建一个对象的数组 public void add(Student08 seud){//创建录入的对象 /** * 利用循环加 阅读全文
posted @ 2018-07-31 16:00 卡多希 阅读(123) 评论(0) 推荐(0)
摘要: } //声明一个数组 String[] num = { "a", "c", "u", "b", "e","p", "f", "z"}; String num1[]=new String[num.length+1];//声明一个比原数组长度加1 System.out.print("原序:"); for 阅读全文
posted @ 2018-07-26 09:01 卡多希 阅读(1382) 评论(0) 推荐(0)