jdk/test/java/util/concurrent/BlockingQueue/PollMemoryLeak.java
author dl
Tue, 25 Aug 2009 19:19:42 -0700
changeset 3708 f838f712922e
parent 2 90ce3da70b43
child 4110 ac033ba6ede4
permissions -rw-r--r--
6868712: Improve concurrent queue tests Summary: Fix all known flaky tests, plus minor maintenance Reviewed-by: martin, chegar
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @bug 6236036 6264015
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @compile PollMemoryLeak.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @run main/othervm -Xmx8m PollMemoryLeak
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @summary  Checks for OutOfMemoryError when an unbounded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * number of aborted timed waits occur without a signal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.util.concurrent.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public class PollMemoryLeak {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    public static void main(String[] args) throws InterruptedException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        final BlockingQueue[] qs = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
            new LinkedBlockingQueue(10),
3708
f838f712922e 6868712: Improve concurrent queue tests
dl
parents: 2
diff changeset
    49
//             new LinkedTransferQueue(),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            new ArrayBlockingQueue(10),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            new SynchronousQueue(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            new SynchronousQueue(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        final long start = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        final long end = start + 10 * 1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        while (System.currentTimeMillis() < end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
            for (BlockingQueue q : qs)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                q.poll(1, TimeUnit.NANOSECONDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
}