finally fixed the database for multithreading.