You can masturbate. This may not always be possible and you might have to try alternative 3 below.
You can have sex. This may not always be possible (too young, no partner, no time, no place, etc) and you might have to try alternative 3 below.
Change the subject. Think of other things. Do your math homework. Write a novel that is not about sex. Clean your room. Walk the dog. Choke a chicken. Double-click your mouse.