jdk/test/javax/management/monitor/MultiMonitorTest.java
changeset 44100 a5803b63fc79
parent 30376 2ccf2cf7ea48
child 44423 306c020eb154
equal deleted inserted replaced
44006:5b8abcec4b80 44100:a5803b63fc79
     1 /*
     1 /*
     2  * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   114         stringProxy.setNotifyDiffer(true);
   114         stringProxy.setNotifyDiffer(true);
   115 
   115 
   116         // A couple of granularity periods to detect bad behaviour
   116         // A couple of granularity periods to detect bad behaviour
   117         Thread.sleep(2);
   117         Thread.sleep(2);
   118 
   118 
       
   119         System.out.println("Checking for all listeners to be 0");
   119         if (!listenersAreAll(0, listeners)) {
   120         if (!listenersAreAll(0, listeners)) {
   120             System.out.println("TEST FAILED: listeners not all 0");
   121             System.out.println("TEST FAILED: listeners not all 0");
   121             System.exit(1);
   122             System.exit(1);
   122         }
   123         }
   123 
   124 
   124         for (int i = 0; i < 3; i++)
   125         for (int i = 0; i < 3; i++)
   125             proxies[i].start();
   126             proxies[i].start();
   126 
   127 
   127         long startTime = System.currentTimeMillis();
   128         System.out.println("Waiting for listeners to all : " + N);
   128         while (!listenersAreAll(N, listeners)
   129         int iterations = 0;
   129                && System.currentTimeMillis() < startTime + 5000)
   130         while (!listenersAreAll(N, listeners)) {
   130             Thread.sleep(1);
   131             Thread.sleep(500);
   131 
   132 
   132         // More time for bad behaviour
   133             if (++iterations == 10) {
   133         Thread.sleep(1000);
   134                for (int i = 0; i < listeners.length; i++) {
   134 
   135                    System.out.print(" " + listeners[i].getCount());
   135         if (!listenersAreAll(N, listeners)) {
   136                }
   136             System.out.print("TEST FAILED: listener counts wrong:");
   137                System.out.println();
   137             for (int i = 0; i < listeners.length; i++)
   138                iterations = 0;
   138                 System.out.print(" " + listeners[i].getCount());
   139             }
   139             System.out.println();
       
   140             System.exit(1);
       
   141         }
   140         }
   142 
   141 
   143         for (int i = 0; i < 3; i++) {
   142         for (int i = 0; i < 3; i++) {
   144             proxies[i].stop();
   143             proxies[i].stop();
   145             for (int j = 0; j < N; j++)
   144             for (int j = 0; j < N; j++)