jdk/test/java/util/concurrent/ConcurrentQueues/ConcurrentQueueLoops.java
author dl
Mon, 02 Nov 2009 17:25:38 -0800
changeset 4110 ac033ba6ede4
parent 3708 f838f712922e
child 5506 202f599c92aa
permissions -rw-r--r--
6865582: jsr166y - jsr166 maintenance update 6865571: Add a lightweight task framework known as ForkJoin 6445158: Phaser - an improved CyclicBarrier 6865579: Add TransferQueue/LinkedTransferQueue Reviewed-by: martin, chegar, dice
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * This file is available under and governed by the GNU General Public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * License version 2 only, as published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * However, the following notice accompanied the original version of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * file:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * Written by Doug Lea with assistance from members of JCP JSR-166
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * Expert Group and released to the public domain, as explained at
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * http://creativecommons.org/licenses/publicdomain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @test
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    36
 * @bug 4486658 6785442
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    37
 * @run main ConcurrentQueueLoops 8 123456
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @summary Checks that a set of threads can repeatedly get and modify items
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.util.concurrent.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.util.concurrent.atomic.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public class ConcurrentQueueLoops {
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    46
    ExecutorService pool;
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    47
    AtomicInteger totalItems;
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    48
    boolean print;
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    49
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    50
    // Suitable for benchmarking.  Overriden by args[0] for testing.
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    51
    int maxStages = 20;
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    52
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    53
    // Suitable for benchmarking.  Overriden by args[1] for testing.
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    54
    int items = 1024 * 1024;
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    55
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    56
    Collection<Queue<Integer>> concurrentQueues() {
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    57
        List<Queue<Integer>> queues = new ArrayList<Queue<Integer>>();
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    58
        queues.add(new ConcurrentLinkedQueue<Integer>());
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    59
        queues.add(new ArrayBlockingQueue<Integer>(items, false));
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    60
        //queues.add(new ArrayBlockingQueue<Integer>(count, true));
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    61
        queues.add(new LinkedBlockingQueue<Integer>());
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    62
        queues.add(new LinkedBlockingDeque<Integer>());
4110
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents: 3708
diff changeset
    63
        queues.add(new LinkedTransferQueue<Integer>());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    65
        // Following additional implementations are available from:
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    66
        // http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    67
        // queues.add(new SynchronizedLinkedListQueue<Integer>());
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    68
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    69
        // Avoid "first fast, second slow" benchmark effect.
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    70
        Collections.shuffle(queues);
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    71
        return queues;
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    72
    }
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    73
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    74
    void test(String[] args) throws Throwable {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        if (args.length > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            maxStages = Integer.parseInt(args[0]);
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    77
        if (args.length > 1)
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    78
            items = Integer.parseInt(args[1]);
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    79
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    80
        for (Queue<Integer> queue : concurrentQueues())
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    81
            test(queue);
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    82
    }
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    83
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    84
    void test(final Queue<Integer> q) throws Throwable {
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    85
        System.out.println(q.getClass().getSimpleName());
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    86
        pool = Executors.newCachedThreadPool();
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    87
        print = false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        print = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        System.out.println("Warmup...");
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    91
        oneRun(1, items, q);
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    92
        //Thread.sleep(100);
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    93
        oneRun(3, items, q);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        Thread.sleep(100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        print = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        for (int i = 1; i <= maxStages; i += (i+1) >>> 1) {
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
    98
            oneRun(i, items, q);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        pool.shutdown();
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   101
        check(pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
   }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   104
    class Stage implements Callable<Integer> {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        final Queue<Integer> queue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        final CyclicBarrier barrier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        int items;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        Stage (Queue<Integer> q, CyclicBarrier b, int items) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            queue = q;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            barrier = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            this.items = items;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        public Integer call() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            // Repeatedly take something from queue if possible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            // transform it, and put back in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                barrier.await();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                int l = 4321;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                int takes = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                for (;;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    Integer item = queue.poll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                    if (item != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                        ++takes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                        l = LoopHelpers.compute2(item.intValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    else if (takes != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                        totalItems.getAndAdd(-takes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                        takes = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    else if (totalItems.get() <= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                    l = LoopHelpers.compute1(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    if (items > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                        --items;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                        queue.offer(new Integer(l));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                    else if ( (l & (3 << 5)) == 0) // spinwait
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                        Thread.sleep(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                return new Integer(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            }
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   143
            catch (Throwable t) { unexpected(t); return null; }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   147
    void oneRun(int n, int items, final Queue<Integer> q) throws Exception {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        CyclicBarrier barrier = new CyclicBarrier(n + 1, timer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        totalItems = new AtomicInteger(n * items);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        ArrayList<Future<Integer>> results = new ArrayList<Future<Integer>>(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        for (int i = 0; i < n; ++i)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            results.add(pool.submit(new Stage(q, barrier, items)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        if (print)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            System.out.print("Threads: " + n + "\t:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        barrier.await();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        int total = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        for (int i = 0; i < n; ++i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            Future<Integer> f = results.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            Integer r = f.get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            total += r.intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        long endTime = System.nanoTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        long time = endTime - timer.startTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        if (print)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            System.out.println(LoopHelpers.rightJustify(time / (items * n)) + " ns per item");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        if (total == 0) // avoid overoptimization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            System.out.println("useless result: " + total);
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   170
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
3414
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   172
    //--------------------- Infrastructure ---------------------------
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   173
    volatile int passed = 0, failed = 0;
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   174
    void pass() {passed++;}
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   175
    void fail() {failed++; Thread.dumpStack();}
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   176
    void fail(String msg) {System.err.println(msg); fail();}
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   177
    void unexpected(Throwable t) {failed++; t.printStackTrace();}
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   178
    void check(boolean cond) {if (cond) pass(); else fail();}
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   179
    void equal(Object x, Object y) {
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   180
        if (x == null ? y == null : x.equals(y)) pass();
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   181
        else fail(x + " not equal to " + y);}
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   182
    public static void main(String[] args) throws Throwable {
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   183
        new ConcurrentQueueLoops().instanceMain(args);}
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   184
    public void instanceMain(String[] args) throws Throwable {
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   185
        try {test(args);} catch (Throwable t) {unexpected(t);}
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   186
        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
cdf768813b4d 6785442: ConcurrentLinkedQueue.remove() and poll() can both remove the same element
dl
parents: 2
diff changeset
   187
        if (failed > 0) throw new AssertionError("Some tests failed");}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
}