write FLAG into db
multithread