|
40 | 40 | import sun.hotspot.WhiteBox; |
41 | 41 |
|
42 | 42 | public class TestWBDeflateIdleMonitors { |
| 43 | + static final int N_DELAY = 1000; // delay between tries |
| 44 | + static final int N_TRIES = 5; // number of times to try deflation |
43 | 45 |
|
44 | 46 | public static void main(String args[]) throws Exception { |
45 | 47 | ProcessBuilder pb = ProcessTools.createTestJvm( |
@@ -68,9 +70,22 @@ public static void main(String args[]) { |
68 | 70 | Asserts.assertEQ(wb.isMonitorInflated(obj), true, |
69 | 71 | "Monitor should be inflated."); |
70 | 72 | } |
71 | | - boolean did_deflation = wb.deflateIdleMonitors(); |
72 | | - Asserts.assertEQ(did_deflation, true, |
73 | | - "deflateIdleMonitors() should have worked."); |
| 73 | + for (int cnt = 1; cnt <= N_TRIES; cnt++) { |
| 74 | + System.out.println("Deflation try #" + cnt); |
| 75 | + boolean did_deflation = wb.deflateIdleMonitors(); |
| 76 | + Asserts.assertEQ(did_deflation, true, |
| 77 | + "deflateIdleMonitors() should have worked."); |
| 78 | + if (!wb.isMonitorInflated(obj)) { |
| 79 | + // Deflation worked so no more retries needed. |
| 80 | + break; |
| 81 | + } |
| 82 | + try { |
| 83 | + System.out.println("Deflation try #" + cnt + " failed. " |
| 84 | + + "Delaying before retry."); |
| 85 | + Thread.sleep(N_DELAY); |
| 86 | + } catch (InterruptedException ie) { |
| 87 | + } |
| 88 | + } |
74 | 89 | Asserts.assertEQ(wb.isMonitorInflated(obj), false, |
75 | 90 | "Monitor should be deflated."); |
76 | 91 | } |
|
0 commit comments