1056 |
|
* @param c the collection to transfer elements into |
1057 |
|
* @return the number of elements transferred |
1058 |
|
*/ |
1059 |
< |
protected int drainTasksTo(Collection<ForkJoinTask<?>> c) { |
1059 |
> |
protected int drainTasksTo(Collection<? super ForkJoinTask<?>> c) { |
1060 |
|
int n = submissionQueue.drainTo(c); |
1061 |
|
ForkJoinWorkerThread[] ws = workers; |
1062 |
|
if (ws != null) { |
1122 |
|
public void shutdown() { |
1123 |
|
checkPermission(); |
1124 |
|
transitionRunStateTo(SHUTDOWN); |
1125 |
< |
if (canTerminateOnShutdown(runControl)) |
1125 |
> |
if (canTerminateOnShutdown(runControl)) { |
1126 |
> |
if (workers == null) { // shutting down before workers created |
1127 |
> |
final ReentrantLock lock = this.workerLock; |
1128 |
> |
lock.lock(); |
1129 |
> |
try { |
1130 |
> |
if (workers == null) { |
1131 |
> |
terminate(); |
1132 |
> |
transitionRunStateTo(TERMINATED); |
1133 |
> |
termination.signalAll(); |
1134 |
> |
} |
1135 |
> |
} finally { |
1136 |
> |
lock.unlock(); |
1137 |
> |
} |
1138 |
> |
} |
1139 |
|
terminateOnShutdown(); |
1140 |
+ |
} |
1141 |
|
} |
1142 |
|
|
1143 |
|
/** |