Java分布式应用学习笔记04JDK的并发包的集合总结---后篇
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException { if (e == null) throw new NullPointerException();long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { for (;;) { if (count != items.length) { insert(e); return true; } if (nanos <= 0) return false; try { nanos = notFull.awaitNanos(nanos); } catch (InterruptedException ie) { notFull.signal(); // propagate to non-interrupted thread throw ie; } } } finally { lock.unlock(); } }
public static int getSum() {return sum.incrementAndGet();}
if (compareAndSet(current, next)) return next;
public final boolean compareAndSet(int expect, int update) {return unsafe.compareAndSwapInt(this, valueOffset, expect, update); }?
楼主这还不算深入?看来我可以洗洗睡了。 6 楼 sunshine09120 2011-08-04 谢谢分享啊,lz还有没有多线程的文章啊。 7 楼 suhuanzheng7784877 2011-08-04 sunshine09120 写道谢谢分享啊,lz还有没有多线程的文章啊。