i am having a issue with multiple threads inserting into a single table in database using hibernate. Every thread generates some data and then inserts them into a table. Problem is that inserting is processed by only 1 thread, because of database locks. What is the best workaround, so the threads can all insert in the same time? I tried to have 1 dedicated thread that will be writing into table and others will be generating data. But the data is generated way faster then inserted, so it doesn't solve my problem.
My only idea is to create own database/tables for each thread, but that seems kinda weird to me, because i don't know how many threads i will be creating in advance. Is there a better solution?