787N/A/*
1472N/A * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
787N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
787N/A *
787N/A * This code is free software; you can redistribute it and/or modify it
787N/A * under the terms of the GNU General Public License version 2 only, as
787N/A * published by the Free Software Foundation.
787N/A *
787N/A * This code is distributed in the hope that it will be useful, but WITHOUT
787N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
787N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
787N/A * version 2 for more details (a copy is included in the LICENSE file that
787N/A * accompanied this code).
787N/A *
787N/A * You should have received a copy of the GNU General Public License version
787N/A * 2 along with this work; if not, write to the Free Software Foundation,
787N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
787N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
787N/A *
787N/A */
787N/A
787N/A/*
787N/A * @test
787N/A * @bug 6772683
787N/A * @summary Thread.isInterrupted() fails to return true on multiprocessor PC
787N/A * @run main/othervm InterruptedTest
787N/A */
787N/A
787N/Apublic class InterruptedTest {
787N/A
787N/A public static void main(String[] args) throws Exception {
787N/A Thread workerThread = new Thread("worker") {
787N/A public void run() {
787N/A System.out.println("Worker thread: running...");
787N/A while (!Thread.currentThread().isInterrupted()) {
787N/A }
787N/A System.out.println("Worker thread: bye");
787N/A }
787N/A };
787N/A System.out.println("Main thread: starts a worker thread...");
787N/A workerThread.start();
787N/A System.out.println("Main thread: waits at most 5s for the worker thread to die...");
787N/A workerThread.join(5000); // Wait 5 sec to let run() method to be compiled
787N/A int ntries = 0;
787N/A while (workerThread.isAlive() && ntries < 5) {
787N/A System.out.println("Main thread: interrupts the worker thread...");
787N/A workerThread.interrupt();
787N/A if (workerThread.isInterrupted()) {
787N/A System.out.println("Main thread: worker thread is interrupted");
787N/A }
787N/A ntries++;
787N/A System.out.println("Main thread: waits for the worker thread to die...");
787N/A workerThread.join(1000); // Wait 1 sec and try again
787N/A }
787N/A if (ntries == 5) {
787N/A System.out.println("Main thread: the worker thread dod not die");
787N/A System.exit(97);
787N/A }
787N/A System.out.println("Main thread: bye");
787N/A }
787N/A
787N/A}