mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8287496: Alternative virtual thread implementation that maps to OS thread
Reviewed-by: rehn, mchung
This commit is contained in:
parent
199832a710
commit
6ff2d89ea1
72 changed files with 694 additions and 173 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue