console oneself; solace oneself — To comfort or soothe one's mind by oneself.
masturbate — To feel sexual pleasure by stimulating one's genitals by oneself.