jdk/test/java/util/concurrent/ConcurrentQueues/RemovePollRace.java
changeset 3708 f838f712922e
parent 3414 cdf768813b4d
child 4110 ac033ba6ede4
equal deleted inserted replaced
3707:67e8505ef721 3708:f838f712922e
    43 import java.util.concurrent.ConcurrentHashMap;
    43 import java.util.concurrent.ConcurrentHashMap;
    44 import java.util.concurrent.ConcurrentLinkedQueue;
    44 import java.util.concurrent.ConcurrentLinkedQueue;
    45 import java.util.concurrent.CountDownLatch;
    45 import java.util.concurrent.CountDownLatch;
    46 import java.util.concurrent.LinkedBlockingDeque;
    46 import java.util.concurrent.LinkedBlockingDeque;
    47 import java.util.concurrent.LinkedBlockingQueue;
    47 import java.util.concurrent.LinkedBlockingQueue;
       
    48 // import java.util.concurrent.LinkedTransferQueue;
    48 import java.util.concurrent.atomic.AtomicLong;
    49 import java.util.concurrent.atomic.AtomicLong;
    49 import java.util.ArrayList;
    50 import java.util.ArrayList;
    50 import java.util.Collection;
    51 import java.util.Collection;
    51 import java.util.Collections;
    52 import java.util.Collections;
    52 import java.util.List;
    53 import java.util.List;
    64         queues.add(new ConcurrentLinkedQueue<Boolean>());
    65         queues.add(new ConcurrentLinkedQueue<Boolean>());
    65         queues.add(new ArrayBlockingQueue<Boolean>(count, false));
    66         queues.add(new ArrayBlockingQueue<Boolean>(count, false));
    66         queues.add(new ArrayBlockingQueue<Boolean>(count, true));
    67         queues.add(new ArrayBlockingQueue<Boolean>(count, true));
    67         queues.add(new LinkedBlockingQueue<Boolean>());
    68         queues.add(new LinkedBlockingQueue<Boolean>());
    68         queues.add(new LinkedBlockingDeque<Boolean>());
    69         queues.add(new LinkedBlockingDeque<Boolean>());
    69 
    70 //         queues.add(new LinkedTransferQueue<Boolean>());
    70         try {
       
    71             queues.add((Queue<Boolean>)
       
    72                        Class.forName("java.util.concurrent.LinkedTransferQueue")
       
    73                        .newInstance());
       
    74         } catch (IllegalAccessException e) {
       
    75         } catch (InstantiationException e) {
       
    76         } catch (ClassNotFoundException e) {
       
    77             // OK; not yet added to JDK
       
    78         }
       
    79 
    71 
    80         // Following additional implementations are available from:
    72         // Following additional implementations are available from:
    81         // http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
    73         // http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
    82         // queues.add(new LinkedTransferQueue<Boolean>());
       
    83         // queues.add(new SynchronizedLinkedListQueue<Boolean>());
    74         // queues.add(new SynchronizedLinkedListQueue<Boolean>());
    84 
    75 
    85         // Avoid "first fast, second slow" benchmark effect.
    76         // Avoid "first fast, second slow" benchmark effect.
    86         Collections.shuffle(queues);
    77         Collections.shuffle(queues);
    87         return queues;
    78         return queues;