Since it is impossible to not think, we cannot just try to reject the negative thoughts in this world, but we must choose to think on the positive truths of God. This is where prayer comes in.
In prayer, we have our minds stayed upon God and are not receptive to thoughts that conceive temptation. Temptation or sin must be conceived (James 1:14-15).
It is easier to avoid being tempted by being in constant communion with God, than it is to overcome temptation once it has been conceived.
Paul admonishes the Philippian believers to reflect and meditate upon eight positive principles of thinking that will lead to a victorious Christian life (Philippians 4:8). These are things that are "true," that is: honorable, truthful and upright. Things that are "honest," that is: honorable, truthful, genuine, not characterized by deception or fraud. Things that are "just," that is: what is right, or right conduct; any circumstance, fact or deed that is right. Things that are "pure," free from defilement or impurity. Things that are "lovely," pleasing, agreeable, inspiring love or affection. A "good report," that is: a saying or report that is positive and constructive rather than negative and destructive. "Virtue," which is moral excellence, righteousness and goodness. "Praise," or what is praiseworthy; expressing one's esteem of a person and his virtues.
We need to focus on the good in every area of our lives, recognizing God's hand in even the smallest things will bring peace and keep our hearts and minds following hard after the Lord.