annotate test/compiler/6772683/InterruptedTest.java @ 889:15c5903cf9e1

6865703: G1: Parallelize hot card cache cleanup Summary: Have the GC worker threads clear the hot card cache in parallel by having each worker thread claim a chunk of the card cache and process the cards in that chunk. The size of the chunks that each thread will claim is determined at VM initialization from the size of the card cache and the number of worker threads. Reviewed-by: jmasa, tonyp
author johnc
date Mon, 03 Aug 2009 12:59:30 -0700
parents bd02caa94611
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
787
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
1 /*
844
bd02caa94611 6862919: Update copyright year
xdono
parents: 787
diff changeset
2 * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
787
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
4 *
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
7 * published by the Free Software Foundation.
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
8 *
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
13 * accompanied this code).
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
14 *
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
18 *
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
21 * have any questions.
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
22 *
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
23 */
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
24
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
25 /*
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
26 * @test
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
27 * @bug 6772683
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
28 * @summary Thread.isInterrupted() fails to return true on multiprocessor PC
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
29 * @run main/othervm InterruptedTest
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
30 */
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
31
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
32 public class InterruptedTest {
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
33
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
34 public static void main(String[] args) throws Exception {
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
35 Thread workerThread = new Thread("worker") {
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
36 public void run() {
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
37 System.out.println("Worker thread: running...");
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
38 while (!Thread.currentThread().isInterrupted()) {
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
39 }
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
40 System.out.println("Worker thread: bye");
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
41 }
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
42 };
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
43 System.out.println("Main thread: starts a worker thread...");
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
44 workerThread.start();
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
45 System.out.println("Main thread: waits at most 5s for the worker thread to die...");
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
46 workerThread.join(5000); // Wait 5 sec to let run() method to be compiled
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
47 int ntries = 0;
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
48 while (workerThread.isAlive() && ntries < 5) {
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
49 System.out.println("Main thread: interrupts the worker thread...");
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
50 workerThread.interrupt();
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
51 if (workerThread.isInterrupted()) {
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
52 System.out.println("Main thread: worker thread is interrupted");
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
53 }
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
54 ntries++;
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
55 System.out.println("Main thread: waits for the worker thread to die...");
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
56 workerThread.join(1000); // Wait 1 sec and try again
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
57 }
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
58 if (ntries == 5) {
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
59 System.out.println("Main thread: the worker thread dod not die");
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
60 System.exit(97);
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
61 }
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
62 System.out.println("Main thread: bye");
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
63 }
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
64
aabd393cf1ee 6772683: Thread.isInterrupted() fails to return true on multiprocessor PC
kvn
parents:
diff changeset
65 }