File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Features new in Java 8 and the fly likes Performance with Streams? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Features new in Java 8
Bookmark "Performance with Streams?" Watch "Performance with Streams?" New topic

Performance with Streams?

Saleem Lakhani

Joined: Nov 01, 2004
Posts: 1
Are there any performance gains for using the new Streams in java 8?
Richard Reese
Ranch Hand

Joined: Jul 13, 2011
Posts: 84


There can be but you need to be careful. Streams can be processed either sequentially or concurrently. On small streams, processing them concurrently may take more time than doing them sequentially. You also want to make sure that a stream processed concurrently does not introduce errors. This can occur when there are “sequential” dependencies that can affect the results.

With that said, streams can result in better performance. Better yet, they are easier to build and understand than using more traditional manual multiple threading approaches.

Richard Reese
Java 8 New Features: A Practical Heads-Up Guide
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45335
And welcome to the Ranch
Some people have waited longer than ten years before their first post.
jQuery in Action, 3rd edition
subject: Performance with Streams?
It's not a secret anymore!