test/jdk/javax/management/monitor/ThreadPoolTest.java
author lfoltan
Tue, 20 Feb 2018 07:46:40 -0500
changeset 49026 844bf1deff1a
parent 47216 71c04702a3d5
permissions -rw-r--r--
8196884: VS2017 Multiple Type Cast Conversion Compilation Errors Summary: Change the type of symbolic constant badAddressVal and introduce specific casts to fix multiple type cast conversion compilation errors. Reviewed-by: coleenp, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 5506
diff changeset
     2
 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 6222826 6379712
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary Test that all monitors will be well started when sharing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * a single thread pool.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @author Luis-Miguel Alventosa
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    30
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * @run clean ThreadPoolTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * @run build ThreadPoolTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @run main/othervm/timeout=300 ThreadPoolTest 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @run main/othervm/timeout=300 ThreadPoolTest 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @run main/othervm/timeout=300 ThreadPoolTest 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @run main/othervm/timeout=300 -Djmx.x.monitor.maximum.pool.size=5 ThreadPoolTest 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @run main/othervm/timeout=300 -Djmx.x.monitor.maximum.pool.size=5 ThreadPoolTest 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @run main/othervm/timeout=300 -Djmx.x.monitor.maximum.pool.size=5 ThreadPoolTest 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @run main/othervm/timeout=300 -Djmx.x.monitor.maximum.pool.size=-5 ThreadPoolTest 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @run main/othervm/timeout=300 -Djmx.x.monitor.maximum.pool.size=-5 ThreadPoolTest 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @run main/othervm/timeout=300 -Djmx.x.monitor.maximum.pool.size=-5 ThreadPoolTest 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.util.concurrent.atomic.AtomicInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import javax.management.MBeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import javax.management.MBeanServerFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import javax.management.Notification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import javax.management.NotificationListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import javax.management.monitor.CounterMonitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import javax.management.monitor.GaugeMonitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import javax.management.monitor.Monitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import javax.management.monitor.MonitorNotification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import javax.management.monitor.StringMonitor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public class ThreadPoolTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    static int maxPoolSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static int nTasks;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static Waiter waiter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    static final long MAX_WAITING_TIME = 10000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    // MBean class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public class ObservedObject implements ObservedObjectMBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        private boolean called = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        public Integer getInteger() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            inform("getInteger()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        public Double getDouble() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            inform("getDouble()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            return 0.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        public String getString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            inform("getString()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        private void inform(String prop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            synchronized(waiter) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                if (!called) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                    called = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                    waiter.count();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            echo(">>> TASK "+prop+" is called.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    // MBean interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public interface ObservedObjectMBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        public Integer getInteger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        public Double getDouble();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        public String getString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Run test
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public int runTest(int monitorType) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        ObjectName[] mbeanNames = new ObjectName[nTasks];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        ObservedObject[] monitored = new ObservedObject[nTasks];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        ObjectName[] monitorNames = new ObjectName[nTasks];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        Monitor[] monitor = new Monitor[nTasks];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        String[] attributes = { "Integer", "Double", "String" };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            echo(">>> CREATE MBeanServer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            MBeanServer server = MBeanServerFactory.newMBeanServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            String domain = server.getDefaultDomain();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            for (int i = 0; i < nTasks; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                mbeanNames[i] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    new ObjectName(":type=ObservedObject,instance=" + (i + 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                monitored[i] = new ObservedObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                echo(">>> CREATE ObservedObject = " + mbeanNames[i].toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                server.registerMBean(monitored[i], mbeanNames[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                switch (monitorType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                case 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                    monitorNames[i] = new ObjectName(":type=CounterMonitor," +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                                                     "instance=" + (i + 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    monitor[i] = new CounterMonitor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                case 2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                    monitorNames[i] = new ObjectName(":type=GaugeMonitor," +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                                     "instance=" + (i + 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    monitor[i] = new GaugeMonitor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                case 3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    monitorNames[i] = new ObjectName(":type=StringMonitor," +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                                     "instance=" + (i + 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                    monitor[i] = new StringMonitor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                    echo("Unsupported monitor type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                    return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                echo(">>> CREATE Monitor = " + monitorNames[i].toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                server.registerMBean(monitor[i], monitorNames[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                monitor[i].addObservedObject(mbeanNames[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                monitor[i].setObservedAttribute(attributes[monitorType-1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                monitor[i].setGranularityPeriod(50);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                monitor[i].start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            if (!waiter.waiting(MAX_WAITING_TIME)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                echo("Error, not all "+nTasks+" monitor tasks are called after "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                     +MAX_WAITING_TIME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            for (int i = 0; i < nTasks; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                if (monitor[i] != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                    monitor[i].stop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        echo("All "+nTasks+" monitors are called.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Print message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    private static void echo(String message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        System.out.println(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * Standalone entry point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Run the test and report to stdout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public static void main (String args[]) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        Integer size = Integer.getInteger("jmx.x.monitor.maximum.pool.size");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        if (size == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            maxPoolSize = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            echo(">>> MAXIMUM POOL SIZE = 10 [default value]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            maxPoolSize = size.intValue() < 1 ? 1 : size.intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            echo(">>> MAXIMUM POOL SIZE = " + maxPoolSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        nTasks = maxPoolSize + 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        waiter = new Waiter(nTasks);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        ThreadPoolTest test = new ThreadPoolTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        int error = test.runTest(Integer.parseInt(args[0]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        if (error > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            echo(">>> Unhappy Bye, Bye!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            throw new IllegalStateException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                "Test FAILED: Unexpected Maximum Pool Size Overflow!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            echo(">>> Happy Bye, Bye!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    private static class Waiter {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        public Waiter(int waitedNB) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            this.waitedNB = waitedNB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        public void count() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                counted++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                if (counted == waitedNB) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                    this.notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        public boolean waiting(long timeout) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            final long startTime = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            long toWait = timeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                while(counted < waitedNB && toWait > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                        this.wait(toWait);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                    } catch (InterruptedException ire) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                    toWait = timeout -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                        (System.currentTimeMillis() - startTime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            return counted == waitedNB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        private int waitedNB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        private int counted = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
}