mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8221892: ThreadPoolExecutor: Thread.isAlive() is not equivalent to not being startable
Reviewed-by: martin, dholmes
This commit is contained in:
parent
9f5e9b5b5f
commit
82b990abc9
2 changed files with 47 additions and 2 deletions
|
@ -922,13 +922,13 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
|||
|
||||
if (isRunning(c) ||
|
||||
(runStateLessThan(c, STOP) && firstTask == null)) {
|
||||
if (t.isAlive()) // precheck that t is startable
|
||||
if (t.getState() != Thread.State.NEW)
|
||||
throw new IllegalThreadStateException();
|
||||
workers.add(w);
|
||||
workerAdded = true;
|
||||
int s = workers.size();
|
||||
if (s > largestPoolSize)
|
||||
largestPoolSize = s;
|
||||
workerAdded = true;
|
||||
}
|
||||
} finally {
|
||||
mainLock.unlock();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue