Fixed Database shared thread problem