简体   繁体   中英

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.

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 eg PostgreSQL has COPY .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM