revert previous change to avoid_thread return type (Julien is right

about p_thread expected return type) and added explicit return statement