Mishlen,
That's probably a worry for many people -- that someone will walk in unexpectedly while he/she is masturbating.
Like Daveman said, it's a natural thing to be doing. The janitor should have knocked before entering.
There was a hilarious Seinfeld episode about that (don't know if you watch Seinfeld) -- so it obviously happens, or is a worry, for many. In the Seinfeld episode, George's MOTHER walks in on him! Then she ends up in the hospital, in shock!
I agree with Dave - the janitor probably felt awful. I bet he felt worse that you did.
Try your best not to let his clumsy entry into YOUR apartment affect you. It must have been really traumatic -- but he was the wrong one, not you.
Stef