device counter in threads fixed

 * device counter has not been thread safe