< prev index next > test/hotspot/jtreg/runtime/vthread/JNIMonitor/JNIMonitor.java
Print this page
throw new RuntimeException(e);
}
}
static void runTest(int nThreads, boolean skipUnlock, boolean throwOnExit) throws Throwable {
- final Object monitor = new Object();
+ final Object[] monitors = new Object[nThreads];
+ for (int i = 0; i < nThreads; i++) {
+ monitors[i] = new Object();
+ }
final AtomicReference<Throwable> exception = new AtomicReference();
// Ensure all our VT's operate of the same carrier, sequentially.
ExecutorService scheduler = Executors.newSingleThreadExecutor();
ThreadFactory factory = virtualThreadBuilder(scheduler).factory();
for (int i = 0 ; i < nThreads; i++) {
+ Object monitor = skipUnlock ? monitors[i] : monitors[0];
Thread th = factory.newThread(() -> {
try {
int res = monitorEnter(monitor);
Asserts.assertTrue(res == 0, "monitorEnter should return 0.");
Asserts.assertTrue(Thread.holdsLock(monitor), "monitor should be owned");
< prev index next >