Performance test and result analysis of parallel stream in Java 8
•
Java
Test 1
Number of parallelstream threads
The default is runtime getRuntime(). Availableprocessors () - 1, here is 7
Operation results
Test 2
Change the data to 30 and the sleep to 100
It can be found that the longer the sleep, the more obvious the advantage of parallel stream.
Summary
Parallelstream has more obvious advantages in blocking scenarios. The number of thread pools is runtime by default getRuntime(). Availableprocessors() - 1. If it needs to be modified, set - DJava util. concurrent. ForkJoinPool. common. parallelism=8
The above is all about the knowledge points. Thank you for your support for programming tips.
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码