query wth thread