< prev index next >

test/jdk/java/util/concurrent/ConcurrentQueues/ConcurrentQueueLoops.java

Print this page
rev 51731 : imported patch 8210732


  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  */
  22 
  23 /*
  24  * This file is available under and governed by the GNU General Public
  25  * License version 2 only, as published by the Free Software Foundation.
  26  * However, the following notice accompanied the original version of this
  27  * file:
  28  *
  29  * Written by Doug Lea with assistance from members of JCP JSR-166
  30  * Expert Group and released to the public domain, as explained at
  31  * http://creativecommons.org/publicdomain/zero/1.0/
  32  */
  33 
  34 /*
  35  * @test
  36  * @bug 4486658 6785442
  37  * @summary Checks that a set of threads can repeatedly get and modify items
  38  * @library /lib/testlibrary/
  39  * @run main ConcurrentQueueLoops 8 123456
  40  */
  41 
  42 import static java.util.concurrent.TimeUnit.MILLISECONDS;
  43 
  44 import java.util.ArrayList;
  45 import java.util.Collection;
  46 import java.util.Collections;
  47 import java.util.List;
  48 import java.util.Queue;
  49 import java.util.concurrent.ArrayBlockingQueue;
  50 import java.util.concurrent.ConcurrentLinkedDeque;
  51 import java.util.concurrent.ConcurrentLinkedQueue;
  52 import java.util.concurrent.Callable;
  53 import java.util.concurrent.CyclicBarrier;
  54 import java.util.concurrent.ExecutorService;
  55 import java.util.concurrent.Executors;
  56 import java.util.concurrent.Future;
  57 import java.util.concurrent.LinkedBlockingDeque;
  58 import java.util.concurrent.LinkedBlockingQueue;
  59 import java.util.concurrent.LinkedTransferQueue;
  60 import java.util.concurrent.atomic.AtomicInteger;
  61 import jdk.testlibrary.Utils;
  62 
  63 public class ConcurrentQueueLoops {
  64     static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
  65     ExecutorService pool;
  66     AtomicInteger totalItems;
  67     boolean print;
  68 
  69     // Suitable for benchmarking.  Overridden by args[0] for testing.
  70     int maxStages = 20;
  71 
  72     // Suitable for benchmarking.  Overridden by args[1] for testing.
  73     int items = 1024 * 1024;
  74 
  75     Collection<Queue<Integer>> concurrentQueues() {
  76         List<Queue<Integer>> queues = new ArrayList<>();
  77         queues.add(new ConcurrentLinkedDeque<Integer>());
  78         queues.add(new ConcurrentLinkedQueue<Integer>());
  79         queues.add(new ArrayBlockingQueue<Integer>(items, false));
  80         //queues.add(new ArrayBlockingQueue<Integer>(count, true));
  81         queues.add(new LinkedBlockingQueue<Integer>());




  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  */
  22 
  23 /*
  24  * This file is available under and governed by the GNU General Public
  25  * License version 2 only, as published by the Free Software Foundation.
  26  * However, the following notice accompanied the original version of this
  27  * file:
  28  *
  29  * Written by Doug Lea with assistance from members of JCP JSR-166
  30  * Expert Group and released to the public domain, as explained at
  31  * http://creativecommons.org/publicdomain/zero/1.0/
  32  */
  33 
  34 /*
  35  * @test
  36  * @bug 4486658 6785442
  37  * @summary Checks that a set of threads can repeatedly get and modify items
  38  * @library /test/lib
  39  * @run main ConcurrentQueueLoops 8 123456
  40  */
  41 
  42 import static java.util.concurrent.TimeUnit.MILLISECONDS;
  43 
  44 import java.util.ArrayList;
  45 import java.util.Collection;
  46 import java.util.Collections;
  47 import java.util.List;
  48 import java.util.Queue;
  49 import java.util.concurrent.ArrayBlockingQueue;
  50 import java.util.concurrent.ConcurrentLinkedDeque;
  51 import java.util.concurrent.ConcurrentLinkedQueue;
  52 import java.util.concurrent.Callable;
  53 import java.util.concurrent.CyclicBarrier;
  54 import java.util.concurrent.ExecutorService;
  55 import java.util.concurrent.Executors;
  56 import java.util.concurrent.Future;
  57 import java.util.concurrent.LinkedBlockingDeque;
  58 import java.util.concurrent.LinkedBlockingQueue;
  59 import java.util.concurrent.LinkedTransferQueue;
  60 import java.util.concurrent.atomic.AtomicInteger;
  61 import jdk.test.lib.Utils;
  62 
  63 public class ConcurrentQueueLoops {
  64     static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
  65     ExecutorService pool;
  66     AtomicInteger totalItems;
  67     boolean print;
  68 
  69     // Suitable for benchmarking.  Overridden by args[0] for testing.
  70     int maxStages = 20;
  71 
  72     // Suitable for benchmarking.  Overridden by args[1] for testing.
  73     int items = 1024 * 1024;
  74 
  75     Collection<Queue<Integer>> concurrentQueues() {
  76         List<Queue<Integer>> queues = new ArrayList<>();
  77         queues.add(new ConcurrentLinkedDeque<Integer>());
  78         queues.add(new ConcurrentLinkedQueue<Integer>());
  79         queues.add(new ArrayBlockingQueue<Integer>(items, false));
  80         //queues.add(new ArrayBlockingQueue<Integer>(count, true));
  81         queues.add(new LinkedBlockingQueue<Integer>());


< prev index next >