w6889037的博客 -买球官网平台

`
文章列表
package concurrent.arrayblockingqueue; import java.util.iterator; import java.util.concurrent.arrayblockingqueue; import java.util.concurrent.blockingqueue; import java.util.concurrent.timeunit; /** * arrayblockingqueue长度固定大小 * linkedblockingqueue长度大小可以不固定 * * 插入方法: * add(e e):将指定 ...
package concurrent.concurrentskiplistmap; import java.util.iterator; import java.util.set; import java.util.concurrent.concurrentskiplistmap; /** * concurrentskiplistmap:有序的并发map * */ public class concurrentskiplistmaptest { public static void main(string[] args) { concurrentskipl ...
package concurrent.copyonwritearraylist; import java.util.arraylist; import java.util.collection; import java.util.iterator; import java.util.concurrent.copyonwritearraylist; /** * copyonwritearraylist功能与arraylist类似 * arraylist在对其使用的迭代器遍历期间如果对list中的内容进行修改,会抛异常 * copyonwritearraylist弥补 ...
package concurrent.countdownlatch; import java.util.concurrent.countdownlatch; import java.util.concurrent.cyclicbarrier; import java.util.concurrent.executorservice; import java.util.concurrent.executors; /** * 当调用 countdownlatch的await方法时,所有线程阻塞 * 当countdownlatch不断调用countdown方法使计数器减为0时,所有 ...
package concurrent.cyclicbarrier; import java.util.concurrent.cyclicbarrier; import java.util.concurrent.executorservice; import java.util.concurrent.executors; /** * 设置线程路障 * await方法可以阻挡所有线程通过,当到达路障的线程数量为构造方法初始值时,就会放行 * */ public class cyclicbarriertest { public static void main( ...
package concurrent.exchanger; import java.util.concurrent.exchanger; import java.util.concurrent.executorservice; import java.util.concurrent.executors; /** * 交换数据 * 当两个线程都到达exchanger.exchange(data)的时候就会交换数据 */ public class exchangertest { public static void main(string[] args) { ...
package concurrent.future; import java.util.concurrent.callable; import java.util.concurrent.completionservice; import java.util.concurrent.executorcompletionservice; import java.util.concurrent.executorservice; import java.util.concurrent.executors; import java.util.concurrent.future; imp ...
package concurrent.lock; import java.util.hashmap; import java.util.map; import java.util.concurrent.locks.readwritelock; import java.util.concurrent.locks.reentrantreadwritelock; public class cachedemo { private map cache = new hashmap(); ...
package concurrent.lock; import java.util.concurrent.executorservice; import java.util.concurrent.executors; import java.util.concurrent.semaphore; /** * 信号灯 * 只有拿到信号灯的线程才能执行,没拿到信号灯的要等待 * */ public class semaphoretest { public static void main(string[] args) { executorservice s ...
package concurrent.lock; import java.util.concurrent.locks.condition; import java.util.concurrent.locks.lock; import java.util.concurrent.locks.reentrantlock; public class conditiontest { /** * @param args */ public static void main(string[] args) { final business business ...
package concurrent.lock; import java.util.random; import java.util.concurrent.locks.readwritelock; import java.util.concurrent.locks.reentrantreadwritelock; public class readwritelocktest { public static void main(string[] args) { final queue3 q3 = new queue3(); for(int i=0;i<3;i ...
package concurrent.lock; import java.util.concurrent.locks.lock; import java.util.concurrent.locks.reentrantlock; public class printmsg{ private lock lock=new reentrantlock(); public void print(string name){ while(true){ lock.lock(); try{ for(int i=0;i
1、固定线程池: package concurrent.threadpool; import java.util.concurrent.executorservice; import java.util.concurrent.executors; /** * 固定线程池 * 使用executors.newfixedthreadpool(3)方法指定池中允许执行线程的个数 * 如果超过这个线程个数,后面的线程就会等待 */ public class fixedthreadpooltest { public static void main(string[] ar ...
global site tag (gtag.js) - google analytics