8164169: Miscellaneous changes imported from jsr166 CVS 2016-09

Reviewed-by: martin, psandoz, shade
This commit is contained in:
Doug Lea 2016-09-12 13:14:49 -07:00
parent 56cff174b6
commit 60cd28abd7
53 changed files with 104 additions and 156 deletions

View File

@ -81,8 +81,8 @@ import java.util.function.Consumer;
* Java Collections Framework</a>.
*
* @author Josh Bloch and Doug Lea
* @since 1.6
* @param <E> the type of elements held in this deque
* @since 1.6
*/
public class ArrayDeque<E> extends AbstractCollection<E>
implements Deque<E>, Cloneable, Serializable

View File

@ -749,11 +749,11 @@ public class PriorityQueue<E> extends AbstractQueue<E>
/**
* Saves this queue to a stream (that is, serializes it).
*
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
* @serialData The length of the array backing the instance is
* emitted (int), followed by all of its elements
* (each an {@code Object}) in the proper order.
* @param s the stream
* @throws java.io.IOException if an I/O error occurs
*/
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException {

View File

@ -136,9 +136,9 @@ import java.util.function.Supplier;
* }}</pre>
*
* @author Doug Lea
* @since 1.8
* @param <T> The result type returned by this future's {@code join}
* and {@code get} methods
* @since 1.8
*/
public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {

View File

@ -132,10 +132,10 @@ import java.util.concurrent.locks.ReentrantLock;
* <i>happen-before</i> actions following a successful return from the
* corresponding {@code await()} in other threads.
*
* @since 1.5
* @see CountDownLatch
*
* @author Doug Lea
* @since 1.5
*/
public class CyclicBarrier {
/**

View File

@ -68,7 +68,7 @@ package java.util.concurrent;
* private boolean subscribed; // true after first subscribe
* public synchronized void subscribe(Subscriber<? super Boolean> subscriber) {
* if (subscribed)
* subscriber.onError(new IllegalStateException()); // only one allowed
* subscriber.onError(new IllegalStateException()); // only one allowed
* else {
* subscribed = true;
* subscriber.onSubscribe(new OneShotSubscription(subscriber, executor));

View File

@ -130,7 +130,7 @@ import java.util.concurrent.locks.LockSupport;
* </table>
*
* <p>The common pool is by default constructed with default
* parameters, but these may be controlled by setting three
* parameters, but these may be controlled by setting the following
* {@linkplain System#getProperty system properties}:
* <ul>
* <li>{@code java.util.concurrent.ForkJoinPool.common.parallelism}
@ -3241,7 +3241,7 @@ public class ForkJoinPool extends AbstractExecutorService {
* An ACC to restrict permissions for the factory itself.
* The constructed workers have no permissions set.
*/
private static final AccessControlContext innocuousAcc;
private static final AccessControlContext INNOCUOUS_ACC;
static {
Permissions innocuousPerms = new Permissions();
innocuousPerms.add(modifyThreadPermission);
@ -3249,7 +3249,7 @@ public class ForkJoinPool extends AbstractExecutorService {
"enableContextClassLoaderOverride"));
innocuousPerms.add(new RuntimePermission(
"modifyThreadGroup"));
innocuousAcc = new AccessControlContext(new ProtectionDomain[] {
INNOCUOUS_ACC = new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(null, innocuousPerms)
});
}
@ -3260,7 +3260,7 @@ public class ForkJoinPool extends AbstractExecutorService {
public ForkJoinWorkerThread run() {
return new ForkJoinWorkerThread.
InnocuousForkJoinWorkerThread(pool);
}}, innocuousAcc);
}}, INNOCUOUS_ACC);
}
}

View File

@ -72,8 +72,8 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* protected synchronized Object getNextAvailableItem() {
* for (int i = 0; i < MAX_AVAILABLE; ++i) {
* if (!used[i]) {
* used[i] = true;
* return items[i];
* used[i] = true;
* return items[i];
* }
* }
* return null; // not reached
@ -82,11 +82,11 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* protected synchronized boolean markAsUnused(Object item) {
* for (int i = 0; i < MAX_AVAILABLE; ++i) {
* if (item == items[i]) {
* if (used[i]) {
* used[i] = false;
* return true;
* } else
* return false;
* if (used[i]) {
* used[i] = false;
* return true;
* } else
* return false;
* }
* }
* return false;

View File

@ -554,8 +554,9 @@ public class SubmissionPublisher<T> implements Flow.Publisher<T>,
while (r != null) {
BufferedSubscription<T> nextRetry = r.nextRetry;
r.nextRetry = null;
int stat = (nanos > 0L) ? r.timedOffer(item, nanos) :
r.offer(item);
int stat = (nanos > 0L)
? r.timedOffer(item, nanos)
: r.offer(item);
if (stat == 0 && onDrop != null &&
onDrop.test(r.subscriber, item))
stat = r.offer(item);

View File

@ -617,6 +617,9 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
/** Per-thread task counter */
volatile long completedTasks;
// TODO: switch to AbstractQueuedLongSynchronizer and move
// completedTasks into the lock word.
/**
* Creates with given first task and thread from ThreadFactory.
* @param firstTask the first task (null if none)

View File

@ -193,7 +193,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
/**
* Atomically increments the current value,
* with memory effects as specified by {@link VarHandle#addAndGet}.
* with memory effects as specified by {@link VarHandle#getAndAdd}.
*
* <p>Equivalent to {@code addAndGet(1)}.
*
@ -205,7 +205,7 @@ public class AtomicInteger extends Number implements java.io.Serializable {
/**
* Atomically decrements the current value,
* with memory effects as specified by {@link VarHandle#addAndGet}.
* with memory effects as specified by {@link VarHandle#getAndAdd}.
*
* <p>Equivalent to {@code addAndGet(-1)}.
*

View File

@ -154,13 +154,13 @@ import jdk.internal.vm.annotation.ReservedStackAccess;
* long stamp = sl.tryOptimisticRead();
* double currentX = x, currentY = y;
* if (!sl.validate(stamp)) {
* stamp = sl.readLock();
* try {
* currentX = x;
* currentY = y;
* } finally {
* sl.unlockRead(stamp);
* }
* stamp = sl.readLock();
* try {
* currentX = x;
* currentY = y;
* } finally {
* sl.unlockRead(stamp);
* }
* }
* return Math.sqrt(currentX * currentX + currentY * currentY);
* }

View File

@ -38,10 +38,8 @@
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Collection;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.TreeSet;

View File

@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.concurrent.atomic.AtomicLong;
/**
* Misc utilities in JSR166 performance tests
*/

View File

@ -43,7 +43,6 @@ import java.util.List;
import java.util.SplittableRandom;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.LinkedTransferQueue;

View File

@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.concurrent.atomic.AtomicLong;
/**
* Misc utilities in JSR166 performance tests
*/

View File

@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.concurrent.atomic.AtomicLong;
/**
* Misc utilities in JSR166 performance tests
*/

View File

@ -43,7 +43,6 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadLocalRandom;
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
public class OfferRemoveLoops {

View File

@ -22,7 +22,6 @@
*/
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;

View File

@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.concurrent.atomic.AtomicLong;
/**
* Misc utilities in JSR166 performance tests
*/

View File

@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.concurrent.atomic.AtomicLong;
/**
* Misc utilities in JSR166 performance tests
*/

View File

@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.concurrent.atomic.AtomicLong;
/**
* Misc utilities in JSR166 performance tests
*/

View File

@ -33,7 +33,6 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import jdk.testlibrary.Utils;
/**

View File

@ -40,7 +40,6 @@
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.lang.reflect.Field;
import java.util.concurrent.BlockingQueue;

View File

@ -40,7 +40,6 @@
*/
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;

View File

@ -34,7 +34,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import jdk.testlibrary.Utils;
public class TimeOutShrink {

View File

@ -22,7 +22,6 @@
*/
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.UnaryOperator;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

View File

@ -22,27 +22,35 @@
*/
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import jdk.testlibrary.Utils;
/*
* @test
* @bug 8078490
* @summary Test submission and execution of task without joining
* @library /lib/testlibrary/
*/
public class SubmissionTest {
static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
static long millisElapsedSince(long startTime) {
return (System.nanoTime() - startTime) / (1000L * 1000L);
}
public static void main(String[] args) throws Throwable {
final ForkJoinPool e = new ForkJoinPool(1);
final AtomicBoolean b = new AtomicBoolean();
final Runnable setFalse = () -> b.set(false);
for (int i = 0; i < 100000; i++) {
for (int i = 0; i < 30_000; i++) {
b.set(true);
e.execute(setFalse);
long st = System.nanoTime();
long startTime = System.nanoTime();
while (b.get()) {
if (System.nanoTime() - st >= TimeUnit.SECONDS.toNanos(10)) {
if (millisElapsedSince(startTime) >= LONG_DELAY_MS) {
throw new RuntimeException("Submitted task failed to execute");
}
Thread.yield();
}
}
}

View File

@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.concurrent.atomic.AtomicLong;
/**
* Misc utilities in JSR166 performance tests
*/

View File

@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.atomic.AtomicInteger;
import java.io.IOException;
import java.io.ObjectInputStream;

View File

@ -43,7 +43,6 @@ import java.util.SplittableRandom;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.locks.LockSupport;

View File

@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.concurrent.atomic.AtomicLong;
/**
* Misc utilities in JSR166 performance tests
*/

View File

@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.concurrent.atomic.AtomicLong;
/**
* Misc utilities in JSR166 performance tests
*/

View File

@ -22,7 +22,6 @@
/*
* @test
* @run main/othervm/timeout=60 ReadersUnlockAfterWriteUnlock
* @bug 8023234
* @summary StampedLock serializes readers on writer unlock
* @author Dmitry Chyuko
@ -30,26 +29,23 @@
*/
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.StampedLock;
public class ReadersUnlockAfterWriteUnlock {
static final int RNUM = 2;
static final StampedLock sl = new StampedLock();
static volatile boolean isDone;
public static void main(String[] args) throws InterruptedException {
final int RNUM = 2;
final int REPS = 128;
final StampedLock sl = new StampedLock();
final AtomicReference<Throwable> bad = new AtomicReference<>();
static CyclicBarrier iterationStart = new CyclicBarrier(RNUM + 1);
static CyclicBarrier readersHaveLocks = new CyclicBarrier(RNUM);
static CyclicBarrier writerHasLock = new CyclicBarrier(RNUM + 1);
final CyclicBarrier iterationStart = new CyclicBarrier(RNUM + 1);
final CyclicBarrier readersHaveLocks = new CyclicBarrier(RNUM);
final CyclicBarrier writerHasLock = new CyclicBarrier(RNUM + 1);
static class Reader extends Thread {
final String name;
Reader(String name) {
super();
this.name = name;
}
public void run() {
while (!isDone && !isInterrupted()) {
try {
Runnable reader = () -> {
try {
for (int i = 0; i < REPS; i++) {
iterationStart.await();
writerHasLock.await();
long rs = sl.readLock();
@ -59,30 +55,45 @@ public class ReadersUnlockAfterWriteUnlock {
readersHaveLocks.await();
sl.unlockRead(rs);
} catch (Exception e) {
throw new IllegalStateException(e);
}
} catch (Throwable ex) {
ex.printStackTrace();
bad.set(ex);
}
}
}
};
public static void main(String[] args) throws InterruptedException {
for (int r = 0 ; r < RNUM; ++r) {
new Reader("r" + r).start();
Thread[] threads = new Thread[RNUM];
for (int i = 0 ; i < RNUM; i++) {
Thread thread = new Thread(reader, "Reader");
threads[i] = thread;
thread.start();
}
int i;
for (i = 0; i < 1024; ++i) {
for (int i = 0; i < REPS; i++) {
try {
iterationStart.await();
long ws = sl.writeLock();
writerHasLock.await();
Thread.sleep(10);
awaitWaitState(threads);
sl.unlockWrite(ws);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
isDone = true;
for (Thread thread : threads)
thread.join();
if (bad.get() != null)
throw new AssertionError(bad.get());
}
static void awaitWaitState(Thread[] threads) {
restart: for (;;) {
for (Thread thread : threads) {
if (thread.getState() != Thread.State.WAITING) {
Thread.yield();
continue restart;
}
}
break;
}
}
}

View File

@ -31,7 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicIntegerArray;
import junit.framework.Test;

View File

@ -31,7 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLongArray;
import junit.framework.Test;

View File

@ -31,7 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReferenceArray;
import junit.framework.Test;

View File

@ -59,7 +59,6 @@ import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;

View File

@ -38,7 +38,6 @@ import static java.util.Spliterator.NONNULL;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;

View File

@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

View File

@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;

View File

@ -42,7 +42,6 @@ import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import junit.framework.Test;

View File

@ -40,7 +40,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CompletionService;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;

View File

@ -296,12 +296,11 @@ public class ForkJoinPool8Test extends JSR166TestCase {
RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
final Thread myself = Thread.currentThread();
final Thread currentThread = Thread.currentThread();
// test join()
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
assertNull(f.join());
Thread.interrupted();
assertEquals(21, f.result);
@ -310,8 +309,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
try {
f.join();
shouldThrow();
@ -323,8 +321,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
try {
f.join();
shouldThrow();
@ -336,8 +333,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
// test quietlyJoin()
f = new FibAction(8);
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
assertEquals(21, f.result);
@ -346,8 +342,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCancelled(f);
@ -355,8 +350,7 @@ public class ForkJoinPool8Test extends JSR166TestCase {
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCompletedAbnormally(f, f.getException());

View File

@ -35,7 +35,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.Arrays;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;

View File

@ -35,9 +35,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;

View File

@ -1264,7 +1264,7 @@ public class JSR166TestCase extends TestCase {
* Sleeps until the given time has elapsed.
* Throws AssertionFailedError if interrupted.
*/
void sleep(long millis) {
static void sleep(long millis) {
try {
delay(millis);
} catch (InterruptedException fail) {

View File

@ -285,12 +285,11 @@ public class RecursiveActionTest extends JSR166TestCase {
RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
final Thread myself = Thread.currentThread();
final Thread currentThread = Thread.currentThread();
// test join()
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
assertNull(f.join());
Thread.interrupted();
assertEquals(21, f.result);
@ -299,8 +298,7 @@ public class RecursiveActionTest extends JSR166TestCase {
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
try {
f.join();
shouldThrow();
@ -312,8 +310,7 @@ public class RecursiveActionTest extends JSR166TestCase {
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
try {
f.join();
shouldThrow();
@ -325,8 +322,7 @@ public class RecursiveActionTest extends JSR166TestCase {
// test quietlyJoin()
f = new FibAction(8);
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
assertEquals(21, f.result);
@ -335,8 +331,7 @@ public class RecursiveActionTest extends JSR166TestCase {
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCancelled(f);
@ -344,8 +339,7 @@ public class RecursiveActionTest extends JSR166TestCase {
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCompletedAbnormally(f, f.getException());
@ -385,22 +379,20 @@ public class RecursiveActionTest extends JSR166TestCase {
public void realRun() throws InterruptedException {
FibAction[] fibActions = sq.take();
FibAction f;
final Thread myself = Thread.currentThread();
final Thread currentThread = Thread.currentThread();
// test join() ------------
f = fibActions[0];
assertFalse(ForkJoinTask.inForkJoinPool());
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
assertNull(f.join());
assertTrue(Thread.interrupted());
assertEquals(21, f.result);
checkCompletedNormally(f);
f = fibActions[1];
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
try {
f.join();
shouldThrow();
@ -410,8 +402,7 @@ public class RecursiveActionTest extends JSR166TestCase {
}
f = fibActions[2];
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
try {
f.join();
shouldThrow();
@ -423,23 +414,20 @@ public class RecursiveActionTest extends JSR166TestCase {
// test quietlyJoin() ---------
f = fibActions[3];
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
f.quietlyJoin();
assertTrue(Thread.interrupted());
assertEquals(21, f.result);
checkCompletedNormally(f);
f = fibActions[4];
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
f.quietlyJoin();
assertTrue(Thread.interrupted());
checkCancelled(f);
f = fibActions[5];
myself.interrupt();
assertTrue(myself.isInterrupted());
currentThread.interrupt();
f.quietlyJoin();
assertTrue(Thread.interrupted());
assertTrue(f.getException() instanceof FJException);

View File

@ -44,7 +44,6 @@ import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Delayed;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;

View File

@ -45,7 +45,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;

View File

@ -44,7 +44,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.StampedLock;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import junit.framework.Test;

View File

@ -37,24 +37,14 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Flow;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SubmissionPublisher;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.stream.Stream;
import junit.framework.Test;
import junit.framework.TestSuite;
import static java.util.concurrent.Flow.Publisher;
import static java.util.concurrent.Flow.Subscriber;
import static java.util.concurrent.Flow.Subscription;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
public class SubmissionPublisherTest extends JSR166TestCase {

View File

@ -44,7 +44,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

View File

@ -55,7 +55,6 @@ import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.Test;