首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Java分布式应用学习札记04JDK的并发包的集合总结-后篇

2013-09-11 
Java分布式应用学习笔记04JDK的并发包的集合总结---后篇public boolean offer(E e, long timeout, TimeUni

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还有没有多线程的文章啊。
恩,会分享的
我的异常网推荐解决方案:java并发集合,http://www.myexception.cn/java-other/371723.html

热点排行