在不需要时使用 ForkJoinPool 有什么缺点?
What is the disadvantage of using a ForkJoinPool when it is not needed?
想象一个场景,其中一个任务可以分成多个子任务,每个子任务都执行一些较长的 运行ning 过程。假设这个繁重的任务只发生在提交给服务器的请求中的 5/100。为这 5% 的任务使用 ForkJoinPool 是否明智?将小任务拆分为更小的子任务并使用 ForkJoinPool 来 运行 表示小任务有什么缺点?
假设我无法决定是否拆分任务,因此我默认拆分所有任务并运行放在一个ForkJoinPool上。
我最近在 java 文档中看到了这个,
ForkJoinTasks should perform relatively small amounts of computation. Large tasks should be split into smaller subtasks, usually via recursive
decomposition. As a very rough rule of thumb, a task should perform more than 100 and less than 10000 basic computational steps, and should avoid indefinite looping. If tasks are too big, then parallelism cannot improve throughput. If too small, then memory and internal task maintenance overhead may overwhelm processing.
想象一个场景,其中一个任务可以分成多个子任务,每个子任务都执行一些较长的 运行ning 过程。假设这个繁重的任务只发生在提交给服务器的请求中的 5/100。为这 5% 的任务使用 ForkJoinPool 是否明智?将小任务拆分为更小的子任务并使用 ForkJoinPool 来 运行 表示小任务有什么缺点?
假设我无法决定是否拆分任务,因此我默认拆分所有任务并运行放在一个ForkJoinPool上。
我最近在 java 文档中看到了这个,
ForkJoinTasks should perform relatively small amounts of computation. Large tasks should be split into smaller subtasks, usually via recursive
decomposition. As a very rough rule of thumb, a task should perform more than 100 and less than 10000 basic computational steps, and should avoid indefinite looping. If tasks are too big, then parallelism cannot improve throughput. If too small, then memory and internal task maintenance overhead may overwhelm processing.