kevin_Aberathna
kevin_Aberathna

Reputation: 471

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.

Upvotes: 3

Views: 136

Answers (1)

Karol Dowbecki
Karol Dowbecki

Reputation: 44942

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.

Upvotes: 3

Related Questions