handle db in different thread