Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parallel streams in a non-daemon thread

What if I used java 8 parallel stream in non-daemon thread.? Is it gonna perform correctly. Currently I'm using for loops and there are millions of records to send to database. I'm using batch insert with separate thread and still its not perform enough. Is it possible to use parallel stream in this case.

like image 856
kavin_Ab Avatar asked May 15 '26 13:05

kavin_Ab


1 Answers

In JVM a daemon thread is a thread that does not prevent said JVM from exiting. A daemon thread will execute the task the same way a normal non-daemon thread would and there will be no performance difference.

The most efficient way to insert millions of records into a database is usually to use the database provided tool e.g. PostgreSQL has COPY.

like image 157
Karol Dowbecki Avatar answered May 17 '26 03:05

Karol Dowbecki