O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting ready

Among many other features, Java 9 introduced these four interfaces in the java.util.concurrent.Flow class:

Flow.Publisher<T> - producer of items (messages) of type TFlow.Subscriber<T> - receiver of messages of type TFlow.Subscription - links producer and receiverFlow.Processor<T,R> - acts as both producer and receiver

With this, Java stepped into the world of reactive programming--programming with the asynchronous processing of data streams.

We discussed streams in Chapter 3, Modular Programming and pointed out that they are not data structures, as they do not keep data in memory. The stream pipeline does nothing until an element is emitted. Such a model allows minimal resource allocation and uses resources only as needed. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required