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

What are the basic functions of Java9

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "what are the basic functions of Java9". 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!

JEP 266improvement Plan

JEP 266 is a member of Oracle's draft JDK enhancement protocol, in which a large number of concurrency updates have been made. According to the proposal, the features to be updated are:

Support for Reactive Streams publish-subscribe framework interface

Update CompletableFuture API, such as support for latency, timeout, subclassing, and other methods

Other general improvements, such as minor adjustments and javadoc specification rewriting

This article focuses on the first two improvements. First, Java 9 will support Reactive Streams, an improvement program from the Java community that aims to improve developers' concurrent workflows. Second, there are several fixer-uppers provided by CompletableFuture API that allow developers to return to Future.

Flow class

A Flow class will be nested within the Reactive Streams publish-subscribe framework, as well as the SubmissionPublisher that developers can use to create custom components.

Starting from the top, Reactive Streams mainly solves the problem of back pressure (back-pressure). When the rate of incoming tasks is greater than the processing capacity of the system, data processing will create a buffer for unprocessed data.

At the same time, we talked to Konrad Malawski, a senior developer on the Akka team, who is part of the Reactive Streams project and explained the importance of Reactive Streams and how to use it.

Oracle points out that the new enhancements will include "a small interface whose definition conforms to broad participation (from Reactive Stream initiative)", which is the source of the Flow class.

Reactive Streams consists of four Java interfaces:

Processor (Processor)

Publisher (Publisher)

Subscriber (Subscriber)

Subscription (Subscription)

The Flow class allows interrelated interfaces and static methods to establish flow control components, where publishers generate items consumed by one or more subscribers, each managed by subscribers.

Reactive Streams is built under the java.util.concurrent.Flow container object, where developers can find Flow.Publisher, a functional interface for assignment targets used as lambda expressions or method references. This interface makes it easier for developers to generate Flow.Subscription elements and link them together.

Another element, Flow.Subscriber, is the asynchronous working mechanism, which is triggered by the request. It can request multiple elements from Flow.Subscription, and developers can customize the buffer size as needed.

These interfaces are suitable for concurrent and distributed asynchronous settings, and the communication between them depends on a simple form of flow control that can be used to avoid resource management problems.

Interested users can view the code examples under java.util.concurrent.Flow.

There are already some third-party libraries that implement the Reactive Streams interface, so you don't have to wait for the release of Java 9 to try it.

New features of CompletableFuture

Java 8 introduces CompletableFuture, which inherits from Future. Futures is very useful, when we do not want or do not need a direct calculation result, we will receive a Future object to hold the actual result of the allocation when the calculation is complete. This can be done explicitly by calling the complete () method without waiting asynchronously. It also allows you to build pipeline data flows in a series of operations.

In this way, any type of available value can use the default return value in Future, even if the calculation is not complete. This will also be part of the CompletableFuture proposal update, including delays and timeouts, better support for subclassing, and some practical methods. "what are the basic functions of Java9?" that's it. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report