jdk/test/javax/swing/system/6799345/TestShutdown.java
author dcubed
Wed, 20 Jun 2012 14:18:25 -0700
changeset 13092 3b4aad065f27
parent 7668 d4a77089c587
child 31448 1066345d2a8a
permissions -rw-r--r--
7175255: symlinks are wrong, which caused jdk8-promote-2 to fail (client/64/64 directories in debuginfo zips) Summary: Fix bad paths in client/64 and server/64 debug info and symlink creation Reviewed-by: ohair, dholmes
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
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 6820
diff changeset
     2
 * Copyright (c) 2009, 2010, 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
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    29
   @run main TestShutdown
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    30
*/
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
import java.awt.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    33
import java.awt.event.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    34
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    35
import java.util.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    36
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    37
import javax.swing.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    38
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    39
import sun.awt.*;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    40
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    41
public class TestShutdown
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    42
{
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    43
    private static AppContext targetAppContext;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    44
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    45
    private static JFrame f;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    46
    private static JTextField tf;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    47
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    48
    private static volatile boolean exceptionsOccurred = false;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    49
    private static volatile boolean appcontextInitDone = false;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    50
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    51
    private static int timerValue = 0;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    52
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    53
    public static void main(String[] args)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    54
        throws Exception
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    55
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    56
        ThreadGroup tg = new TestThreadGroup("TTG");
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    57
        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
    58
        t.start();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    59
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    60
        while (!appcontextInitDone)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    61
        {
6820
bd6e9b4e1460 6828273: javax/swing/system/6799345/TestShutdown.java test fails with RuntimeException.
art
parents: 5506
diff changeset
    62
            Thread.sleep(1000);
2485
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    63
        }
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
        targetAppContext.dispose();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    66
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    67
        if (exceptionsOccurred)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    68
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    69
            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
    70
        }
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
    static void initGUI()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    74
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    75
        f = new JFrame("F");
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    76
        f.setBounds(100, 100, 200, 100);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    77
        tf = new JTextField("Test");
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    78
        f.add(tf);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    79
        f.setVisible(true);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    80
    }
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
    static void startGUI()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    83
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    84
        // caret blink Timer
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    85
        tf.requestFocusInWindow();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    86
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    87
        // misc Timer
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    88
        ActionListener al = new ActionListener()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    89
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    90
            @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    91
            public void actionPerformed(ActionEvent ae)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    92
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    93
                System.out.println("Timer tick: " + timerValue++);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
    94
            }
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
        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
    97
    }
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
    static class TestThreadGroup extends ThreadGroup
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   100
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   101
        public TestThreadGroup(String name)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   102
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   103
            super(name);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   104
        }
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
        @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   107
        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
   108
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   109
            if (t instanceof ThreadDeath)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   110
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   111
                // this one is expected, rethrow
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   112
                throw (ThreadDeath)t;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   113
            }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   114
            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
   115
                               "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
   116
            t.printStackTrace(System.err);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   117
            exceptionsOccurred = true;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   118
        }
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
    static class TestRunnable implements Runnable
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   122
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   123
        @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   124
        public void run()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   125
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   126
            SunToolkit stk = (SunToolkit)Toolkit.getDefaultToolkit();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   127
            targetAppContext = stk.createNewAppContext();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   128
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   129
            // 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
   130
            SwingUtilities.invokeLater(new Runnable()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   131
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   132
                @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   133
                public void run()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   134
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   135
                    initGUI();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   136
                }
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
            stk.realSync();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   139
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   140
            // start some Timers
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   141
            SwingUtilities.invokeLater(new Runnable()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   142
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   143
                @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   144
                public void run()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   145
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   146
                    startGUI();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   147
                }
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
            // start multiple SwingWorkers
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   151
            while (!Thread.interrupted())
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   152
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   153
                try
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   154
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   155
                    new TestSwingWorker().execute();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   156
                    Thread.sleep(40);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   157
                }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   158
                catch (Exception e)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   159
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   160
                    // exception here is expected, skip
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   161
                    break;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   162
                }
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
    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
   168
    {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   169
        @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   170
        public String doInBackground()
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   171
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   172
            Random r = new Random();
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   173
            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
   174
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   175
                try
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   176
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   177
                    int delay = r.nextInt() % 50;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   178
                    Thread.sleep(delay);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   179
                    publish(delay);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   180
                }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   181
                catch (Exception z)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   182
                {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   183
                    break;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   184
                }
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
            if (!appcontextInitDone)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   187
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   188
                appcontextInitDone = true;
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   189
            }
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   190
            return "Done";
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   191
        }
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
        @Override
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   194
        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
   195
        {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   196
            for (Integer i : chunks)
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   197
            {
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   198
                System.err.println("Processed: " + i);
dc7165666847 6799345: JFC demos threw exception in the Java Console when applets are closed
art
parents:
diff changeset
   199
            }
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
}