|
1 | 1 | /* |
2 | | - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
31 | 31 | */ |
32 | 32 |
|
33 | 33 | import java.lang.ref.Reference; |
| 34 | +import java.util.ArrayList; |
| 35 | +import java.util.List; |
34 | 36 |
|
35 | 37 | public class DynamicCodeGeneratedTest { |
36 | 38 | static { |
37 | 39 | System.loadLibrary("DynamicCodeGenerated"); |
38 | 40 | } |
39 | 41 | public static native void changeEventNotificationMode(); |
40 | 42 |
|
41 | | - public static void main(String[] args) { |
| 43 | + public static void main(String[] args) throws Exception { |
42 | 44 | // Try to enable DynamicCodeGenerated event while it is posted |
43 | 45 | // using JvmtiDynamicCodeEventCollector from VtableStubs::find_stub |
44 | | - Thread t = new Thread(() -> { |
| 46 | + Thread threadChangeENM = new Thread(() -> { |
45 | 47 | changeEventNotificationMode(); |
46 | 48 | }); |
47 | | - t.setDaemon(true); |
48 | | - t.start(); |
| 49 | + threadChangeENM.setDaemon(true); |
| 50 | + threadChangeENM.start(); |
49 | 51 |
|
50 | | - for (int i = 0; i < 2000; i++) { |
51 | | - new Thread(() -> { |
52 | | - String result = "string" + System.currentTimeMillis(); |
53 | | - Reference.reachabilityFence(result); |
54 | | - }).start(); |
| 52 | + for (int i = 0; i < 10; i++) { |
| 53 | + List<Thread> threads = new ArrayList(); |
| 54 | + for (int j = 0; j < 200; j++) { |
| 55 | + Thread t = new Thread(() -> { |
| 56 | + String result = "string" + System.currentTimeMillis(); |
| 57 | + Reference.reachabilityFence(result); |
| 58 | + }); |
| 59 | + threads.add(t); |
| 60 | + t.start(); |
| 61 | + } |
| 62 | + for (Thread t: threads) { |
| 63 | + t.join(); |
| 64 | + } |
55 | 65 | } |
56 | 66 | } |
57 | 67 | } |
0 commit comments