collision_detection function called from separate thread.