Sometimes we think uncomfortable thoughts that we would not be happy to share with our friends and neighbors. This is about as common as the many inappropriate things that can happen in dreams.
The most important thing is not to judge ourselves. By not judging it is possible to step outside and witness such thoughts without becoming them or thinking less of ourselves. When this is done, it then becomes possible to change thoughts by contemplating the feelings that helped to create the thoughts, and their sources. Then one can get a better perspective on what is actually going on.
Most importantly, one does not have to act on a less than charitable impulse, and the exercise of detachment done routinely makes it more and more likely that one will not say, do or even think those mean thoughts.