< prev index next > test/jdk/java/lang/Thread/virtual/JfrEvents.java
Print this page
assertContainsPinnedEvent(recording, vthread);
}
}
/**
- * Test jdk.VirtualThreadPinned event when waiting for a class initializer.
+ * Test jdk.VirtualThreadPinned event when waiting for a class initializer while pinned.
*/
@Test
- void testWaitingForClassInitializer() throws Exception {
+ void testWaitingForClassInitializerWhenPinned() throws Exception {
class TestClass {
static {
LockSupport.park();
}
static void m() {
started1.set(true);
TestClass.m();
});
Thread vthread2 = Thread.ofVirtual().unstarted(() -> {
started2.set(true);
- TestClass.m();
+ VThreadPinner.runPinned(() -> {
+ TestClass.m();
+ });
});
try {
// start first virtual thread and wait for it to start + park
vthread1.start();
// start second virtual thread and wait for it to start
vthread2.start();
awaitTrue(started2);
- // give time for second virtual thread to wait on the MutexLocker
+ // give time for second virtual thread to wait in VM
Thread.sleep(3000);
} finally {
LockSupport.unpark(vthread1);
vthread1.join();
< prev index next >