摘要:
public class MyLinkedList<E> { private Node first; private int size; public int size(){ return size; } @Override public String toString() { if(size == 阅读全文
摘要:
public class CompletableFuture2 { public static void main(String[] args) throws InterruptedException { // thenAcceptBoth(); // acceptEither(); // runA 阅读全文
摘要:
Futrue的缺点有(1)get方法会阻塞 ,(2)不支持注册回调方法 ,(3)不支持级联操作 CompletableFuture弥补了这些缺点 public class CompletableFutureTest { public static void main(String[] args) t 阅读全文
摘要:
ScheduledThreadPoolExecutor可以代替timer,timer的缺点是一个timer启动一个线程,如果任务数量很多,会创建很多线程,不推荐使用。 ScheduledThreadPoolExecutor他有个线程池管理线程管理所有任务,效率更高 public class Sche 阅读全文
摘要:
/** * CyclicBarrier 一组线程相互等待 */ public class Beer { public static void main(String[] args) { final int count = 5; final CyclicBarrier barrier = new Cy 阅读全文
摘要:
/** * 模拟铁人三项 */ public class PhaserTest { private static Random random = new Random(System.currentTimeMillis()); public static void main(String[] args 阅读全文