If the surety is sued separately from his principal, on payment by him of the judgment against him, he shall be entitled to control the judgment and execution against his principal in the same manner as if the judgment and execution were joint; and, if he does not appear as surety in the judgment against him, he may give notice and make the proof and obtain the control in the same manner as provided in cases of joint judgments.