45 |
|
* #setMaintainsParallelism}, the pool attempts to maintain this |
46 |
|
* number of active (or available) threads by dynamically adding, |
47 |
|
* suspending, or resuming internal worker threads, even if some tasks |
48 |
< |
* are waiting to join others. However, no such adjustments are |
49 |
< |
* performed in the face of blocked IO or other unmanaged |
48 |
> |
* are stalled waiting to join others. However, no such adjustments |
49 |
> |
* are performed in the face of blocked IO or other unmanaged |
50 |
|
* synchronization. The nested {@link ManagedBlocker} interface |
51 |
|
* enables extension of the kinds of synchronization accommodated. |
52 |
|
* The target parallelism level may also be changed dynamically |
384 |
|
* |
385 |
|
* @param parallelism the parallelism level |
386 |
|
* @throws IllegalArgumentException if parallelism less than or |
387 |
< |
* equal to zero |
387 |
> |
* equal to zero, or greater than implementation limit |
388 |
|
* @throws SecurityException if a security manager exists and |
389 |
|
* the caller is not permitted to modify threads |
390 |
|
* because it does not hold {@link |
417 |
|
* @param parallelism the parallelism level |
418 |
|
* @param factory the factory for creating new threads |
419 |
|
* @throws IllegalArgumentException if parallelism less than or |
420 |
< |
* equal to zero, or greater than implementation limit |
420 |
> |
* equal to zero, or greater than implementation limit |
421 |
|
* @throws NullPointerException if factory is null |
422 |
|
* @throws SecurityException if a security manager exists and |
423 |
|
* the caller is not permitted to modify threads |
804 |
|
|
805 |
|
/** |
806 |
|
* Returns the maximum number of threads allowed to exist in the |
807 |
< |
* pool. Unless set using {@link #setMaximumPoolSize}, the |
807 |
> |
* pool. Unless set using {@link #setMaximumPoolSize}, the |
808 |
|
* maximum is an implementation-defined value designed only to |
809 |
|
* prevent runaway growth. |
810 |
|
* |
816 |
|
|
817 |
|
/** |
818 |
|
* Sets the maximum number of threads allowed to exist in the |
819 |
< |
* pool. Setting this value has no effect on current pool |
820 |
< |
* size. It controls construction of new threads. |
819 |
> |
* pool. The given value should normally be greater than or equal |
820 |
> |
* to the {@link #getParallelism parallelism} level. Setting this |
821 |
> |
* value has no effect on current pool size. It controls |
822 |
> |
* construction of new threads. |
823 |
|
* |
824 |
|
* @throws IllegalArgumentException if negative or greater than |
825 |
|
* internal implementation limit |
1578 |
|
while (spareStack == null || !tryResumeSpare(dec)) { |
1579 |
|
int counts = workerCounts; |
1580 |
|
if (dec || (dec = casWorkerCounts(counts, --counts))) { |
1579 |
– |
// CAS cheat |
1581 |
|
if (!needSpare(counts, maintainParallelism)) |
1582 |
|
break; |
1583 |
|
if (joinMe.status < 0) |