--- jsr166/src/jsr166y/ForkJoinTask.java 2011/02/22 10:50:51 1.75 +++ jsr166/src/jsr166y/ForkJoinTask.java 2011/06/10 18:10:53 1.79 @@ -1,24 +1,20 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ package jsr166y; import java.io.Serializable; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.RandomAccess; -import java.util.Map; import java.lang.ref.WeakReference; import java.lang.ref.ReferenceQueue; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RunnableFuture; @@ -384,13 +380,13 @@ public abstract class ForkJoinTask im * periods. However, since we do not know when the last joiner * completes, we must use weak references and expunge them. We do * so on each operation (hence full locking). Also, some thread in - * any ForkJoinPool will call helpExpunge when its pool becomes - * isQuiescent. + * any ForkJoinPool will call helpExpungeStaleExceptions when its + * pool becomes isQuiescent. */ static final class ExceptionNode extends WeakReference>{ final Throwable ex; ExceptionNode next; - final long thrower; + final long thrower; // use id not ref to avoid weak cycles ExceptionNode(ForkJoinTask task, Throwable ex, ExceptionNode next) { super(task, exceptionTableRefQueue); this.ex = ex; @@ -406,7 +402,7 @@ public abstract class ForkJoinTask im */ private int setExceptionalCompletion(Throwable ex) { int h = System.identityHashCode(this); - ReentrantLock lock = exceptionTableLock; + final ReentrantLock lock = exceptionTableLock; lock.lock(); try { expungeStaleExceptions(); @@ -431,7 +427,7 @@ public abstract class ForkJoinTask im */ private void clearExceptionalCompletion() { int h = System.identityHashCode(this); - ReentrantLock lock = exceptionTableLock; + final ReentrantLock lock = exceptionTableLock; lock.lock(); try { ExceptionNode[] t = exceptionTable; @@ -476,7 +472,7 @@ public abstract class ForkJoinTask im return null; int h = System.identityHashCode(this); ExceptionNode e; - ReentrantLock lock = exceptionTableLock; + final ReentrantLock lock = exceptionTableLock; lock.lock(); try { expungeStaleExceptions(); @@ -491,7 +487,7 @@ public abstract class ForkJoinTask im if (e == null || (ex = e.ex) == null) return null; if (e.thrower != Thread.currentThread().getId()) { - Class ec = ex.getClass(); + Class ec = ex.getClass(); try { Constructor noArgCtor = null; Constructor[] cs = ec.getConstructors();// public ctors only @@ -542,11 +538,11 @@ public abstract class ForkJoinTask im } /** - * If lock is available, poll any stale refs and remove them. + * If lock is available, poll stale refs and remove them. * Called from ForkJoinPool when pools become quiescent. */ static final void helpExpungeStaleExceptions() { - ReentrantLock lock = exceptionTableLock; + final ReentrantLock lock = exceptionTableLock; if (lock.tryLock()) { try { expungeStaleExceptions();