mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8284161: Implementation of Virtual Threads (Preview)
Co-authored-by: Ron Pressler <rpressler@openjdk.org> Co-authored-by: Alan Bateman <alanb@openjdk.org> Co-authored-by: Erik Österlund <eosterlund@openjdk.org> Co-authored-by: Andrew Haley <aph@openjdk.org> Co-authored-by: Rickard Bäckman <rbackman@openjdk.org> Co-authored-by: Markus Grönlund <mgronlun@openjdk.org> Co-authored-by: Leonid Mesnik <lmesnik@openjdk.org> Co-authored-by: Serguei Spitsyn <sspitsyn@openjdk.org> Co-authored-by: Chris Plummer <cjplummer@openjdk.org> Co-authored-by: Coleen Phillimore <coleenp@openjdk.org> Co-authored-by: Robbin Ehn <rehn@openjdk.org> Co-authored-by: Stefan Karlsson <stefank@openjdk.org> Co-authored-by: Thomas Schatzl <tschatzl@openjdk.org> Co-authored-by: Sergey Kuksenko <skuksenko@openjdk.org> Reviewed-by: lancea, eosterlund, rehn, sspitsyn, stefank, tschatzl, dfuchs, lmesnik, dcubed, kevinw, amenkov, dlong, mchung, psandoz, bpb, coleenp, smarks, egahlin, mseledtsov, coffeys, darcy
This commit is contained in:
parent
5212535a27
commit
9583e3657e
1133 changed files with 95935 additions and 8335 deletions
|
@ -40,10 +40,12 @@ import java.util.ConcurrentModificationException;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import jdk.internal.vm.SharedThreadContainer;
|
||||
|
||||
/**
|
||||
* An {@link ExecutorService} that executes each submitted task using
|
||||
|
@ -477,6 +479,11 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
|||
*/
|
||||
private final Condition termination = mainLock.newCondition();
|
||||
|
||||
/**
|
||||
* The thread container for the worker threads.
|
||||
*/
|
||||
private final SharedThreadContainer container;
|
||||
|
||||
/**
|
||||
* Tracks largest attained pool size. Accessed only under
|
||||
* mainLock.
|
||||
|
@ -726,6 +733,7 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
|||
} finally {
|
||||
ctl.set(ctlOf(TERMINATED, 0));
|
||||
termination.signalAll();
|
||||
container.close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -942,7 +950,7 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
|||
mainLock.unlock();
|
||||
}
|
||||
if (workerAdded) {
|
||||
t.start();
|
||||
container.start(t);
|
||||
workerStarted = true;
|
||||
}
|
||||
}
|
||||
|
@ -1309,6 +1317,9 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
|||
this.keepAliveTime = unit.toNanos(keepAliveTime);
|
||||
this.threadFactory = threadFactory;
|
||||
this.handler = handler;
|
||||
|
||||
String name = Objects.toIdentityString(this);
|
||||
this.container = SharedThreadContainer.create(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue