test/jdk/java/util/concurrent/FutureTask/DoneTimedGetLoops.java
author dl
Sat, 14 Sep 2019 11:26:26 -0700
changeset 58138 1e4270f875ee
parent 47216 71c04702a3d5
permissions -rw-r--r--
8225490: Miscellaneous changes imported from jsr166 CVS 2019-09 Reviewed-by: martin, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
     1
/*
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
     3
 *
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
     6
 * published by the Free Software Foundation.
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
     7
 *
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
     8
 * This code is distributed in the hope that it will be useful, but WITHOUT
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
     9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    10
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    11
 * version 2 for more details (a copy is included in the LICENSE file that
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    12
 * accompanied this code).
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    13
 *
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License version
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    15
 * 2 along with this work; if not, write to the Free Software Foundation,
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    16
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    17
 *
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    18
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    19
 * or visit www.oracle.com if you need additional information or have any
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    20
 * questions.
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    21
 */
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    22
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    23
/*
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 32649
diff changeset
    24
 * This file is available under and governed by the GNU General Public
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 32649
diff changeset
    25
 * License version 2 only, as published by the Free Software Foundation.
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 32649
diff changeset
    26
 * However, the following notice accompanied the original version of this
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 32649
diff changeset
    27
 * file:
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 32649
diff changeset
    28
 *
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    29
 * Written by Martin Buchholz with assistance from members of JCP JSR-166
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    30
 * Expert Group and released to the public domain, as explained at
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    31
 * http://creativecommons.org/publicdomain/zero/1.0/
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    32
 */
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    33
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    34
/*
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    35
 * @test
58138
1e4270f875ee 8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents: 47216
diff changeset
    36
 * @library /test/lib
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    37
 * @run main DoneTimedGetLoops 300
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    38
 * @summary isDone returning true guarantees that subsequent timed get
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    39
 * will never throw TimeoutException.
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    40
 */
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    41
34347
4a17f9e90a0f 8142441: Improve jtreg tests for java.util.concurrent
dl
parents: 32991
diff changeset
    42
import java.util.concurrent.ExecutionException;
4a17f9e90a0f 8142441: Improve jtreg tests for java.util.concurrent
dl
parents: 32991
diff changeset
    43
import java.util.concurrent.FutureTask;
4a17f9e90a0f 8142441: Improve jtreg tests for java.util.concurrent
dl
parents: 32991
diff changeset
    44
import java.util.concurrent.TimeUnit;
4a17f9e90a0f 8142441: Improve jtreg tests for java.util.concurrent
dl
parents: 32991
diff changeset
    45
import java.util.concurrent.atomic.AtomicReference;
58138
1e4270f875ee 8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents: 47216
diff changeset
    46
import jdk.test.lib.Utils;
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    47
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    48
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    49
public class DoneTimedGetLoops {
58138
1e4270f875ee 8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents: 47216
diff changeset
    50
    static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
1e4270f875ee 8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents: 47216
diff changeset
    51
    final long testDurationMillisDefault = 10_000L;
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    52
    final long testDurationMillis;
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    53
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    54
    static class PublicFutureTask extends FutureTask<Boolean> {
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 14856
diff changeset
    55
        static final Runnable noop = new Runnable() { public void run() {} };
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    56
        PublicFutureTask() { super(noop, null); }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    57
        public void set(Boolean v) { super.set(v); }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    58
        public void setException(Throwable t) { super.setException(t); }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    59
    }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    60
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    61
    DoneTimedGetLoops(String[] args) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    62
        testDurationMillis = (args.length > 0) ?
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    63
            Long.valueOf(args[0]) : testDurationMillisDefault;
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    64
    }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    65
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    66
    void test(String[] args) throws Throwable {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    67
        final long testDurationNanos = testDurationMillis * 1000L * 1000L;
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    68
        final long quittingTimeNanos = System.nanoTime() + testDurationNanos;
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    69
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    70
        final AtomicReference<PublicFutureTask> normalRef
43522
f9c6f543c4db 8171886: Miscellaneous changes imported from jsr166 CVS 2017-02
dl
parents: 34347
diff changeset
    71
            = new AtomicReference<>();
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    72
        final AtomicReference<PublicFutureTask> abnormalRef
43522
f9c6f543c4db 8171886: Miscellaneous changes imported from jsr166 CVS 2017-02
dl
parents: 34347
diff changeset
    73
            = new AtomicReference<>();
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    74
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    75
        final Throwable throwable = new Throwable();
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    76
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    77
        abstract class CheckedThread extends Thread {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    78
            CheckedThread(String name) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    79
                super(name);
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    80
                setDaemon(true);
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    81
                start();
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    82
            }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    83
            /** Polls for quitting time. */
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    84
            protected boolean quittingTime() {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    85
                return System.nanoTime() - quittingTimeNanos > 0;
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    86
            }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    87
            /** Polls occasionally for quitting time. */
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    88
            protected boolean quittingTime(long i) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    89
                return (i % 1024) == 0 && quittingTime();
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    90
            }
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 14856
diff changeset
    91
            protected abstract void realRun() throws Exception;
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    92
            public void run() {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    93
                try { realRun(); } catch (Throwable t) { unexpected(t); }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    94
            }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    95
        }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    96
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    97
        Thread setter = new CheckedThread("setter") {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    98
            protected void realRun() {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
    99
                while (! quittingTime()) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   100
                    PublicFutureTask future = new PublicFutureTask();
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   101
                    normalRef.set(future);
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   102
                    future.set(Boolean.TRUE);
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   103
                }}};
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   104
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   105
        Thread setterException = new CheckedThread("setterException") {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   106
            protected void realRun() {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   107
                while (! quittingTime()) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   108
                    PublicFutureTask future = new PublicFutureTask();
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   109
                    abnormalRef.set(future);
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   110
                    future.setException(throwable);
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   111
                }}};
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   112
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   113
        Thread doneTimedGetNormal = new CheckedThread("doneTimedGetNormal") {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   114
            protected void realRun() throws Exception {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   115
                while (! quittingTime()) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   116
                    PublicFutureTask future = normalRef.get();
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   117
                    if (future != null) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   118
                        while (!future.isDone())
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   119
                            ;
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   120
                        check(future.get(0L, TimeUnit.HOURS) == Boolean.TRUE);
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   121
                    }}}};
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   122
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   123
        Thread doneTimedGetAbnormal = new CheckedThread("doneTimedGetAbnormal") {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   124
            protected void realRun() throws Exception {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   125
                while (! quittingTime()) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   126
                    PublicFutureTask future = abnormalRef.get();
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   127
                    if (future != null) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   128
                        while (!future.isDone())
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   129
                            ;
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   130
                        try { future.get(0L, TimeUnit.HOURS); fail(); }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   131
                        catch (ExecutionException t) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   132
                            check(t.getCause() == throwable);
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   133
                        }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   134
                    }}}};
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   135
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   136
        for (Thread thread : new Thread[] {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   137
                 setter,
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   138
                 setterException,
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   139
                 doneTimedGetNormal,
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   140
                 doneTimedGetAbnormal }) {
58138
1e4270f875ee 8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents: 47216
diff changeset
   141
            thread.join(LONG_DELAY_MS + testDurationMillis);
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   142
            if (thread.isAlive()) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   143
                System.err.printf("Hung thread: %s%n", thread.getName());
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   144
                failed++;
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   145
                for (StackTraceElement e : thread.getStackTrace())
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   146
                    System.err.println(e);
58138
1e4270f875ee 8225490: Miscellaneous changes imported from jsr166 CVS 2019-09
dl
parents: 47216
diff changeset
   147
                thread.join(LONG_DELAY_MS);
11689
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   148
            }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   149
        }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   150
    }
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   151
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   152
    //--------------------- Infrastructure ---------------------------
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   153
    volatile int passed = 0, failed = 0;
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   154
    void pass() {passed++;}
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   155
    void fail() {failed++; Thread.dumpStack();}
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   156
    void fail(String msg) {System.err.println(msg); fail();}
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   157
    void unexpected(Throwable t) {failed++; t.printStackTrace();}
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   158
    void check(boolean cond) {if (cond) pass(); else fail();}
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   159
    void equal(Object x, Object y) {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   160
        if (x == null ? y == null : x.equals(y)) pass();
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   161
        else fail(x + " not equal to " + y);}
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   162
    public static void main(String[] args) throws Throwable {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   163
        new DoneTimedGetLoops(args).instanceMain(args);}
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   164
    public void instanceMain(String[] args) throws Throwable {
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   165
        try {test(args);} catch (Throwable t) {unexpected(t);}
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   166
        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   167
        if (failed > 0) throw new AssertionError("Some tests failed");}
ffbfda5c3886 7132378: Race in FutureTask if used with explicit set ( not Runnable )
dl
parents:
diff changeset
   168
}