jdk/test/javax/swing/system/6799345/TestShutdown.java
author hseigel
Wed, 01 Mar 2017 08:00:02 -0500
changeset 46194 5596e6f63072
parent 31448 1066345d2a8a
child 46151 5fa789776f7d
permissions -rw-r--r--
8172307: Remove ununsed JVM API JVM_GetModuleByPackageName() Summary: Remove get_module_by_package_name() etc., and unneeded test. Reviewed-by: sspitsyn, gtriantafill
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2485
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
     1
/*
31448
1066345d2a8a 8076468: Add @modules to tests in jdk_desktop test group
yan
parents: 7668
diff changeset
     2
 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
2485
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
     4
 *
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
     8
 *
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    13
 * accompanied this code).
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    14
 *
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2485
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2485
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2485
diff changeset
    21
 * questions.
2485
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    22
 */
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    23
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    24
/* @test
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    25
   @bug 6799345
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    26
   @summary Tests that no exceptions are thrown from TimerQueue and
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    27
SwingWorker on AppContext shutdown
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    28
   @author art
31448
1066345d2a8a 8076468: Add @modules to tests in jdk_desktop test group
yan
parents: 7668
diff changeset
    29
   @modules java.desktop/sun.awt
2485
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    30
   @run main TestShutdown
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    31
*/
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    32
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    33
import java.awt.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    34
import java.awt.event.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    35
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    36
import java.util.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    37
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    38
import javax.swing.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    39
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    40
import sun.awt.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    41
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    42
public class TestShutdown
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    43
{
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    44
    private static AppContext targetAppContext;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    45
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    46
    private static JFrame f;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    47
    private static JTextField tf;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    48
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    49
    private static volatile boolean exceptionsOccurred = false;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    50
    private static volatile boolean appcontextInitDone = false;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    51
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    52
    private static int timerValue = 0;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    53
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    54
    public static void main(String[] args)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    55
        throws Exception
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    56
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    57
        ThreadGroup tg = new TestThreadGroup("TTG");
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    58
        Thread t = new Thread(tg, new TestRunnable(), "InitThread");
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    59
        t.start();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    60
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    61
        while (!appcontextInitDone)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    62
        {
6820
bd6e9b4e1460 6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents: 5506
diff changeset
    63
            Thread.sleep(1000);
2485
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    64
        }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    65
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    66
        targetAppContext.dispose();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    67
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    68
        if (exceptionsOccurred)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    69
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    70
            throw new RuntimeException("Test FAILED: some exceptions occurred");
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    71
        }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    72
    }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    73
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    74
    static void initGUI()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    75
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    76
        f = new JFrame("F");
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    77
        f.setBounds(100, 100, 200, 100);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    78
        tf = new JTextField("Test");
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    79
        f.add(tf);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    80
        f.setVisible(true);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    81
    }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    82
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    83
    static void startGUI()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    84
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    85
        // caret blink Timer
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    86
        tf.requestFocusInWindow();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    87
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    88
        // misc Timer
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    89
        ActionListener al = new ActionListener()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    90
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    91
            @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    92
            public void actionPerformed(ActionEvent ae)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    93
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    94
                System.out.println("Timer tick: " + timerValue++);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    95
            }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    96
        };
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    97
        new javax.swing.Timer(30, al).start();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    98
    }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    99
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   100
    static class TestThreadGroup extends ThreadGroup
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   101
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   102
        public TestThreadGroup(String name)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   103
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   104
            super(name);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   105
        }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   106
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   107
        @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   108
        public synchronized void uncaughtException(Thread thread, Throwable t)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   109
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   110
            if (t instanceof ThreadDeath)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   111
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   112
                // this one is expected, rethrow
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   113
                throw (ThreadDeath)t;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   114
            }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   115
            System.err.println("Test FAILED: an exception is caught in the " +
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   116
                               "target thread group on thread " + thread.getName());
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   117
            t.printStackTrace(System.err);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   118
            exceptionsOccurred = true;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   119
        }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   120
    }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   121
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   122
    static class TestRunnable implements Runnable
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   123
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   124
        @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   125
        public void run()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   126
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   127
            SunToolkit stk = (SunToolkit)Toolkit.getDefaultToolkit();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   128
            targetAppContext = stk.createNewAppContext();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   129
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   130
            // create and show frame and text field
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   131
            SwingUtilities.invokeLater(new Runnable()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   132
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   133
                @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   134
                public void run()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   135
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   136
                    initGUI();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   137
                }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   138
            });
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   139
            stk.realSync();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   140
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   141
            // start some Timers
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   142
            SwingUtilities.invokeLater(new Runnable()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   143
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   144
                @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   145
                public void run()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   146
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   147
                    startGUI();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   148
                }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   149
            });
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   150
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   151
            // start multiple SwingWorkers
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   152
            while (!Thread.interrupted())
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   153
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   154
                try
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   155
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   156
                    new TestSwingWorker().execute();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   157
                    Thread.sleep(40);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   158
                }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   159
                catch (Exception e)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   160
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   161
                    // exception here is expected, skip
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   162
                    break;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   163
                }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   164
            }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   165
        }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   166
    }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   167
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   168
    static class TestSwingWorker extends SwingWorker<String, Integer>
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   169
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   170
        @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   171
        public String doInBackground()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   172
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   173
            Random r = new Random();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   174
            for (int i = 0; i < 10; i++)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   175
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   176
                try
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   177
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   178
                    int delay = r.nextInt() % 50;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   179
                    Thread.sleep(delay);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   180
                    publish(delay);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   181
                }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   182
                catch (Exception z)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   183
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   184
                    break;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   185
                }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   186
            }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   187
            if (!appcontextInitDone)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   188
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   189
                appcontextInitDone = true;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   190
            }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   191
            return "Done";
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   192
        }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   193
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   194
        @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   195
        public void process(java.util.List<Integer> chunks)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   196
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   197
            for (Integer i : chunks)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   198
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   199
                System.err.println("Processed: " + i);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   200
            }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   201
        }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   202
    }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   203
}