A
A
artshelom2017-05-26 21:45:35
Java
artshelom, 2017-05-26 21:45:35

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

Is this error coming from the code?? (that is, an error in the code)
If not because of the code, then how to fix it ??

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Labunsky, 2017-05-26
@artshelom

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 question

Ask a Question

731 491 924 answers to any question