use sperate thread to access database