wood burning stoves 2.0*
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


JavaRanch » Java Forums » Java » Features new in Java 8
Bookmark "Performance with Streams?" Watch "Performance with Streams?" New topic
Author

Performance with Streams?

Saleem Lakhani
Greenhorn

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

Joined: Jul 13, 2011
Posts: 84
    
    5

Saleem,

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
Sheriff

Joined: Oct 13, 2005
Posts: 39044
    
  23
And welcome to the Ranch
Some people have waited longer than ten years before their first post.
 
GeeCON Prague 2014
 
subject: Performance with Streams?