acquireSharedInterruptibly

countdownlatch也用到了AQS,在CountDownLatch内部写了一个Sync并且继承了AQS这个抽象类重写了AQS中的共享锁方法。首先看到下面这个代码,这块代码主要是判断当前线程是否获取到了共享锁;(在CountDownLatch中,使用的是共享锁机制,因为CountDownLatch并不需要实现互斥的特性)

public final void acquireSharedInterruptibly(int arg) 
throws InterruptedException { 
	if (Thread.interrupted()) 
	throw new InterruptedException(); 
	if (tryAcquireShared(arg) < 0) //state如果不等于0,说明当前线程需要加入到共享锁队列中 
	doAcquireSharedInterruptibly(arg); 
}