When you meet someone better than yourself, turn your thoughts to becoming his equal. When you meet someone not as good as you are, look within and examine your own self.
-Confucius

The first step required to change the way your mind works is to be aware of your thoughts. Only when you catch yourself in a negative thought process is it possible to consciously halt it. This is not something that can be achieved overnight; it requires practice and willpower.