Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the java Fork/Join framework

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to use the java Fork/Join framework". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The Fork/Join framework highlights:

1. If necessary, fork a large task into several sub-tasks (so that it can no longer be split, that is, the critical value of the split), and then summarize the results of each small task by join.

(2) the "work stealing mode" is adopted in the Forkhand join.

3ForkJoin makes more effective use of CPU resources.

4Jing Java 8 optimizes parallel flows, and Stream API can declaratively switch between parallel and serial flows through parallel () and sequential ().

Here is a simple example:

Public class ForkJoinWorkTest extends RecursiveTask {private Long start; private Long end; public static final Long critical = 100000L; public ForkJoinWorkTest (Long start, Long end) {this.start = start; this.end = end;} @ Override protected Long compute () {Long length = end-start; if (length)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report