Book Image

Java 9 Programming By Example

By : Peter Verhas
Book Image

Java 9 Programming By Example

By: Peter Verhas

Overview of this book

This book gets you started with essential software development easily and quickly, guiding you through Java’s different facets. By adopting this approach, you can bridge the gap between learning and doing immediately. You will learn the new features of Java 9 quickly and experience a simple and powerful approach to software development. You will be able to use the Java runtime tools, understand the Java environment, and create Java programs. We then cover more simple examples to build your foundation before diving to some complex data structure problems that will solidify your Java 9 skills. With a special focus on modularity and HTTP 2.0, this book will guide you to get employed as a top notch Java developer. By the end of the book, you will have a firm foundation to continue your journey towards becoming a professional Java developer.
Table of Contents (17 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Reactive programming in Java


Java is not a reactive language. This does not mean that we cannot create reactive programs in Java. There are libraries that support different reactive programming approaches. It is to mention the Akka framework and the ReactiveX that also exist for other languages as well. With Java 9, the JDK starts to support reactive programming, providing a few classes and interfaces for the purpose. We will focus on these features.

The JDK contains the java.util.concurrent.Flow class, which contains related interfaces and some static methods to support flow controlled programs. The model that this class supports is based on Publisher, Subscriber, and Subscription.

As a very simple explanation, a Publisher accepts a subscription from a Subscriber. A Subscriber gets the data it subscribed to when the data is available. The interfaces focus on the very core of the data flow control of the communication and are a bit abstract. No surprise, they are interfaces. However, it may...