Sometime I think about masturbating in class.
Why would you think about things like this?
I like to imagine that I'm in class masturbating.
Thoughts are one thing, but you shouldn't touch yourself in public. There could be a chance someone sees you and becomes horrified.
They are just thoughts and when I actually do it I'm in a private room.
If you only masturbate privately and doing it in public is merely a fantasy, then you aren't doing anything wrong. We all have things that turn us on, but sometimes acting on them is inappropriate.