add thread_db
refine code