1193 |
|
} |
1194 |
|
if (runStateOf(c) == RUNNING && workQueue.offer(command)) { |
1195 |
|
int recheck = ctl.get(); |
1196 |
< |
if (runStateOf(recheck) != RUNNING && remove(command)) |
1196 |
> |
if (runStateOf(recheck) >= STOP && remove(command)) |
1197 |
|
reject(command); |
1198 |
|
else if (workerCountOf(recheck) == 0) |
1199 |
|
addWorker(null, false); |
1564 |
|
* @return true if the task was removed |
1565 |
|
*/ |
1566 |
|
public boolean remove(Runnable task) { |
1567 |
< |
boolean removed = workQueue.remove(task); |
1568 |
< |
tryTerminate(); // In case SHUTDOWN and now empty |
1567 |
> |
boolean removed; |
1568 |
> |
final ReentrantLock mainLock = this.mainLock; |
1569 |
> |
mainLock.lock(); |
1570 |
> |
try { |
1571 |
> |
removed = workQueue.remove(task); |
1572 |
> |
} finally { |
1573 |
> |
mainLock.unlock(); |
1574 |
> |
} |
1575 |
> |
if (removed) |
1576 |
> |
tryTerminate(); // In case SHUTDOWN and now empty |
1577 |
|
return removed; |
1578 |
|
} |
1579 |
|
|