Answer the question
In order to leave comments, you need to log in
How to solve error in streams?
When working with streams, the following error occurs:
Exception in thread "Thread-69" java.lang.OutOfMemoryError: unable to create new native thread
Answer the question
In order to leave comments, you need to log in
The JVM cannot allocate memory to create a new thread. This usually means that there is a loop/recursion somewhere with the creation of a bunch of threads - more than can be created. You can read more here .
UPD
From the above code example, you can immediately say that you should not run one thread for each element of the list (at least on a home PC), especially if the size can be on the order of hundreds. Dig towards Producer-Consumer and similar patterns.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question