Negative thinking comes when result of our efforts are not as per our expectations.
What do you do when you buy an expensive dress for you and one fine day you notice food stains on your favourite dress? Do you throw it away instantly? Do you sit and cry over it for days? No. You immediately decide to wash it with an expensive soap to get rid of stains. Once the stains are gone, you are happy. You start wearing the dress again.
So, negative thinking can be defeated with positive thinking. Because opposite of negative is positive. Your resolve to become good and do good in your life should be stronger than the negative forces in your life.
Only with more positive acts, you can overcome negativity. There is no other way I believe. Perseverance is the key to success.