Java????????????????
???????????? ???????[ 2014/11/10 10:50:36 ] ????????Java ??????? ????????
??????.???????е???????
????????????????????к??????????г?????????????????????????е??????????????ArrayBlockingQueue???????????????????????????ArrayBlockingQueue???Щ???????????·???????????????????????в????????????е???????
????????????ArrayBlockingQueue???е?????????????
public class ArrayBlockingQueue<E> extends AbstractQueue<E>
implements BlockingQueue<E>?? java.io.Serializable {
private static final long serialVersionUID = -817911632652898426L;
/** The queued items */
private final E[] items;
/** items index for next take?? poll or remove */
private int takeIndex;
/** items index for next put?? offer?? or add. */
private int putIndex;
/** Number of items in the queue */
private int count;
/*
* Concurrency control uses the classic two-condition algorithm
* found in any textbook.
*/
/** Main lock guarding all access */
private final ReentrantLock lock;
/** Condition for waiting takes */
private final Condition notEmpty;
/** Condition for waiting puts */
private final Condition notFull;
}
?????????????ArrayBlockingQueue???????洢?????????????????飬takeIndex??putIndex??????????????β?????±?count??????????????????
????lock???????????????notEmpty??notFull??????????
???????濴???ArrayBlockingQueue?????????????????????????汾??
public ArrayBlockingQueue(int capacity) {
}
public ArrayBlockingQueue(int capacity?? boolean fair) {
}
public ArrayBlockingQueue(int capacity?? boolean fair??
Collection<? extends E> c) {
}
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????г??????
????????????????????????????put()??take()??
public void put(E e) throws InterruptedException {
if (e == null) throw new NullPointerException();
final E[] items = this.items;
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
try {
while (count == items.length)
notFull.await();
} catch (InterruptedException ie) {
notFull.signal(); // propagate to non-interrupted thread
throw ie;
}
insert(e);
} finally {
lock.unlock();
}
}
??????put?????????????????????????????????????????ж?????????ж????????????????????????????????????notFull.await()???е????????????ж????????????????????
????????????????????????insert(e)???????????????????
????????????insert??????????
private void insert(E x) {
items[putIndex] = x;
putIndex = inc(putIndex);
++count;
notEmpty.signal();
}
???????????private?????????????????notEmpty???????????????????
??????????take()??????????
public E take() throws InterruptedException {
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
try {
while (count == 0)
notEmpty.await();
} catch (InterruptedException ie) {
notEmpty.signal(); // propagate to non-interrupted thread
throw ie;
}
E x = extract();
return x;
} finally {
lock.unlock();
}
}
??????put??????????????????put???????????notFull??????take???????????notEmpty??????take?????У??????????????????extract?????????????????extract??????????
????private E extract() {
????final E[] items = this.items;
????E x = items[takeIndex];
????items[takeIndex] = null;
????takeIndex = inc(takeIndex);
????--count;
????notFull.signal();
????return x;
????}
??????insert????????????
???????????????????????????????е?????????????????????Object.wait()??Object.notify()????????????????????-????????·????????????????Щ??????????????????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Java???????????Щ???????????????Java????????????????Java?б???Map????????Java Web???????????????Java??????????????д?????Java????????7???????????????????????(java .net ?????)???Java??????????Python??????Java webdriver??λ????????′????е?????Java??д??????????????????Java???????????????JavaScript????????????Java?????????????????? Java???????10??????????????Java?м????????????????java???????ü???????????м???????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????