8287496: Alternative virtual thread implementation that maps to OS thread

Reviewed-by: rehn, mchung
This commit is contained in:
Alan Bateman 2022-06-02 09:02:37 +00:00
parent 199832a710
commit 6ff2d89ea1
72 changed files with 694 additions and 173 deletions

View file

@ -2591,18 +2591,28 @@ public final class System {
}
public void parkVirtualThread() {
VirtualThread.park();
Thread thread = Thread.currentThread();
if (thread instanceof BaseVirtualThread vthread) {
vthread.park();
} else {
throw new WrongThreadException();
}
}
public void parkVirtualThread(long nanos) {
VirtualThread.parkNanos(nanos);
Thread thread = Thread.currentThread();
if (thread instanceof BaseVirtualThread vthread) {
vthread.parkNanos(nanos);
} else {
throw new WrongThreadException();
}
}
public void unparkVirtualThread(Thread thread) {
if (thread instanceof VirtualThread vthread) {
if (thread instanceof BaseVirtualThread vthread) {
vthread.unpark();
} else {
throw new IllegalArgumentException("Not a virtual thread");
throw new WrongThreadException();
}
}