< prev index next >

test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadEventTest/VThreadEventTest.java

Print this page

132         LockSupport.parkNanos(10_000_000L); // will cause extra mount and unmount
133         ready2.countDown();
134     };
135 
136     public static void main(String[] args) throws Exception {
137         if (Runtime.getRuntime().availableProcessors() < 8) {
138             log("WARNING: test expects at least 8 processors.");
139         }
140         try (ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor()) {
141             for (int i = 0; i < TCNT1; i++) {
142                 executorService.execute(test1);
143             }
144             for (int i = 0; i < TCNT2; i++) {
145                 executorService.execute(test2);
146             }
147             for (int i = 0; i < TCNT3; i++) {
148                 executorService.execute(test3);
149             }
150             await(ready0);
151             mready.countDown();
152             await(ready1); // to guaranty state is not State.WAITING after await(mready) in test1()
153             // wait for test1 threads to reach WAITING state in sleep()
154             for (Thread t : test1Threads) {
155                 Thread.State state = t.getState();
156                 log("DBG: state: " + state);
157                 while (state != Thread.State.WAITING) {
158                     Thread.sleep(10);
159                     state = t.getState();
160                     log("DBG: state: " + state);
161                 }
162             }
163 
164             VirtualMachine vm = VirtualMachine.attach(String.valueOf(ProcessHandle.current().pid()));
165             vm.loadAgentLibrary("VThreadEventTest");
166             Thread.sleep(200); // to allow the agent to get ready
167 
168             attached = true;
169             for (Thread t : test1Threads) {
170                  t.interrupt();
171             }
172             ready2.await();
173         }
174         // wait until all VirtualThreadEnd events have been sent
175         for (int sleepNo = 1; threadEndCount() < THREAD_CNT; sleepNo++) {
176             Thread.sleep(100);
177             if (sleepNo % 100 == 0) { // 10 sec period of waiting

132         LockSupport.parkNanos(10_000_000L); // will cause extra mount and unmount
133         ready2.countDown();
134     };
135 
136     public static void main(String[] args) throws Exception {
137         if (Runtime.getRuntime().availableProcessors() < 8) {
138             log("WARNING: test expects at least 8 processors.");
139         }
140         try (ExecutorService executorService = Executors.newVirtualThreadPerTaskExecutor()) {
141             for (int i = 0; i < TCNT1; i++) {
142                 executorService.execute(test1);
143             }
144             for (int i = 0; i < TCNT2; i++) {
145                 executorService.execute(test2);
146             }
147             for (int i = 0; i < TCNT3; i++) {
148                 executorService.execute(test3);
149             }
150             await(ready0);
151             mready.countDown();
152             await(ready1); // to guarantee state is not State.TIMED_WAITING after await(mready) in test1()
153             // wait for test1 threads to reach TIMED_WAITING state in sleep()
154             for (Thread t : test1Threads) {
155                 Thread.State state = t.getState();
156                 log("DBG: state: " + state);
157                 while (state != Thread.State.TIMED_WAITING) {
158                     Thread.sleep(10);
159                     state = t.getState();
160                     log("DBG: state: " + state);
161                 }
162             }
163 
164             VirtualMachine vm = VirtualMachine.attach(String.valueOf(ProcessHandle.current().pid()));
165             vm.loadAgentLibrary("VThreadEventTest");
166             Thread.sleep(200); // to allow the agent to get ready
167 
168             attached = true;
169             for (Thread t : test1Threads) {
170                  t.interrupt();
171             }
172             ready2.await();
173         }
174         // wait until all VirtualThreadEnd events have been sent
175         for (int sleepNo = 1; threadEndCount() < THREAD_CNT; sleepNo++) {
176             Thread.sleep(100);
177             if (sleepNo % 100 == 0) { // 10 sec period of waiting
< prev index next >