How it works...

The main element of this example is Spliterator. This interface defines methods that can be used to process and partition a source of elements to be used, for example, the source of a Stream object. You will rarely need to use a Spliterator object directly. Only if you want a different behavior--that is, if you want to implement your own data structure and create Stream from it--use a Spliterator object.

Spliterator has a set of characteristics that defines its behavior. They are as follows:

  • CONCURRENT: The data source can be safely modified concurrently
  • DISTINCT: All the elements of the data source are distinct
  • IMMUTABLE: Elements can be added, deleted, or replaced in the data source
  • NONNULL: There's no null element in the ...

Get Java 9 Concurrency Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.