Detailed explanation of stream flow examples of new features in Java 8
What is a stream?
A stream stream is a data channel used to manipulate a sequence of elements generated by a data source (collection, array, etc.).
Advantages of stream: declarative, composable and parallel. These three features make stream operation more concise, flexible and efficient.
Stream operation has two characteristics: multiple operations can be linked to run, and internal iteration.
Stream can be divided into parallel stream and serial stream. Stream API can declaratively switch between parallel stream and sequential stream through parallel() and sequential(). There is no need to elaborate on serial flow. Parallel flow is mainly to adapt to the current era of multi-core machines and improve the utilization of system CPU and memory. Parallel flow is to divide a content into multiple data blocks and process the flow of each data block with different threads. java1. 8. The fork / join framework is used for parallel flow. For the fork / join framework, please refer to http://ifeve.com/talk-concurrency-forkjoin/ study.