For me, sexual thoughts are a way to "cope" with anxiety. It's in fact an escape mechanism. When I'm masturbating or having sex, my anxiety is totally gone. But when I orgasm, then I'm back in reality and anxiety immediatedly comes back.
If the thought would give you pleasure you would not feel anxiety If you have anxiety you might find the sexual thought disgusting or fearful. Maybe a compulsive thought