摘要:
参考:https://www.cnblogs.com/liuyun1995/p/9305273.html ThreadPoolExecutor1 executorService1 = new ThreadPoolExecutor1(3) 线程池的线程是懒初始化的,第一个任务来了创建一下执行,执行完了 阅读全文
摘要:
public class BB { public static void main(String[] args) throws Exception { System.out.println(parseInt("11100000000000000000000000000000",2)); System.out.println(parseInt("111000... 阅读全文
摘要:
00000000 00000001 00000010 00000011 …… 01111111 127 = 2^7-1 10000000负的最大 01111111 10000000 -2^7 = -128 10000001 01111110 01111111 -(2^7-1) = -127 1000 阅读全文
摘要:
@SuppressWarnings("restriction") public abstract class AbstractQueuedSynchronizer1 extends AbstractOwnableSynchronizer1 implements java.io.Serializable { private static final long serialVersionUI... 阅读全文
摘要:
@SuppressWarnings("restriction") public class ReentrantReadWriteLock1 implements ReadWriteLock, java.io.Serializable { private static final long serialVersionUID = -6992448646407690164L; priv... 阅读全文
摘要:
public class ReentrantLock1 implements Lock, java.io.Serializable { private static final long serialVersionUID = 7373984872572414699L; //创建一个ReentrantLock1里面有一个sync,里面有一个state和队列。 //多个线程竞... 阅读全文
摘要:
public class CyclicBarrierExample3 { private static CyclicBarrier1 barrier = new CyclicBarrier1(3, new Runnable() { @Override public void run() { System.out.printl... 阅读全文
摘要:
public class CountDownLatchExample1 { public static void main(String[] args) throws Exception { ExecutorService exec = Executors1.newCachedThreadPool(); final CountDownLatch1 coun... 阅读全文
摘要:
public class SemaphoreExample1 { private final static int threadCount = 20; public static void main(String[] args) throws Exception { ExecutorService exec = Executors1.newCachedThrea... 阅读全文
摘要:
代码在后面 读锁 = 共享锁 读锁写锁,公用一个Sync AQS state。 写锁是排他的,看到有人获取锁,他不会去获取,他获取了锁,别人也不会进来获取锁。 写锁的获取跟ReentarntLock一样,每次加1,是一个独占锁,只要有人获取了锁,自己就去排队,排队时候节点是EXCLUSIVE的节点, 阅读全文