81 |
|
private static final int MAX_THREADS = 0x7FFF; |
82 |
|
|
83 |
|
/** |
84 |
< |
* Factory for creating new ForkJoinWorkerThreads. A |
85 |
< |
* ForkJoinWorkerThreadFactory must be defined and used for |
86 |
< |
* ForkJoinWorkerThread subclasses that extend base functionality |
87 |
< |
* or initialize threads with different contexts. |
84 |
> |
* Factory for creating new {@link ForkJoinWorkerThread}s. |
85 |
> |
* A {@code ForkJoinWorkerThreadFactory} must be defined and used |
86 |
> |
* for {@code ForkJoinWorkerThread} subclasses that extend base |
87 |
> |
* functionality or initialize threads with different contexts. |
88 |
|
*/ |
89 |
|
public static interface ForkJoinWorkerThreadFactory { |
90 |
|
/** |
578 |
|
* @throws NullPointerException if task is null |
579 |
|
* @throws RejectedExecutionException if pool is shut down |
580 |
|
*/ |
581 |
< |
public <T> void execute(ForkJoinTask<T> task) { |
581 |
> |
public void execute(ForkJoinTask<?> task) { |
582 |
|
doSubmit(task); |
583 |
|
} |
584 |
|
|
787 |
|
* Setting this value has no effect on current pool size. It |
788 |
|
* controls construction of new threads. |
789 |
|
* |
790 |
< |
* @throws IllegalArgumentException if negative or greater then |
790 |
> |
* @throws IllegalArgumentException if negative or greater than |
791 |
|
* internal implementation limit |
792 |
|
*/ |
793 |
|
public void setMaximumPoolSize(int newMax) { |
1735 |
|
|
1736 |
|
/** |
1737 |
|
* Interface for extending managed parallelism for tasks running |
1738 |
< |
* in ForkJoinPools. A ManagedBlocker provides two methods. |
1738 |
> |
* in {@link ForkJoinPool}s. |
1739 |
> |
* |
1740 |
> |
* <p>A {@code ManagedBlocker} provides two methods. |
1741 |
|
* Method {@code isReleasable} must return {@code true} if |
1742 |
|
* blocking is not necessary. Method {@code block} blocks the |
1743 |
|
* current thread if necessary (perhaps internally invoking |
1780 |
|
|
1781 |
|
/** |
1782 |
|
* Blocks in accord with the given blocker. If the current thread |
1783 |
< |
* is a ForkJoinWorkerThread, this method possibly arranges for a |
1784 |
< |
* spare thread to be activated if necessary to ensure parallelism |
1785 |
< |
* while the current thread is blocked. If |
1786 |
< |
* {@code maintainParallelism} is {@code true} and the pool supports |
1787 |
< |
* it ({@link #getMaintainsParallelism}), this method attempts to |
1788 |
< |
* maintain the pool's nominal parallelism. Otherwise it activates |
1789 |
< |
* a thread only if necessary to avoid complete starvation. This |
1790 |
< |
* option may be preferable when blockages use timeouts, or are |
1791 |
< |
* almost always brief. |
1783 |
> |
* is a {@link ForkJoinWorkerThread}, this method possibly |
1784 |
> |
* arranges for a spare thread to be activated if necessary to |
1785 |
> |
* ensure parallelism while the current thread is blocked. |
1786 |
> |
* |
1787 |
> |
* <p>If {@code maintainParallelism} is {@code true} and the pool |
1788 |
> |
* supports it ({@link #getMaintainsParallelism}), this method |
1789 |
> |
* attempts to maintain the pool's nominal parallelism. Otherwise |
1790 |
> |
* it activates a thread only if necessary to avoid complete |
1791 |
> |
* starvation. This option may be preferable when blockages use |
1792 |
> |
* timeouts, or are almost always brief. |
1793 |
|
* |
1794 |
< |
* <p> If the caller is not a ForkJoinTask, this method is behaviorally |
1795 |
< |
* equivalent to |
1794 |
> |
* <p>If the caller is not a {@link ForkJoinTask}, this method is |
1795 |
> |
* behaviorally equivalent to |
1796 |
|
* <pre> {@code |
1797 |
|
* while (!blocker.isReleasable()) |
1798 |
|
* if (blocker.block()) |
1799 |
|
* return; |
1800 |
|
* }</pre> |
1801 |
< |
* If the caller is a ForkJoinTask, then the pool may first |
1802 |
< |
* be expanded to ensure parallelism, and later adjusted. |
1801 |
> |
* |
1802 |
> |
* If the caller is a {@code ForkJoinTask}, then the pool may |
1803 |
> |
* first be expanded to ensure parallelism, and later adjusted. |
1804 |
|
* |
1805 |
|
* @param blocker the blocker |
1806 |
|
* @param maintainParallelism if {@code true} and supported by |