The problem is that all parallel streams use common fork-join thread pool and if you submit a long-running task, you effectively block all threads in the pool. Consequently you block all other tasks that are using parallel streams. Imagine a servlet environment, when one request calls getStockInfo() and another one countPrimes(). One will block the other one even though each of them requires different resources. What's worse, you can not specify thread pool for parallel streams, the whole class loader has to use the same one.
Read full article from Think twice before using Java 8 parallel streams | Javalobby
No comments:
Post a Comment