One cannot give up thinking of women, for thinking in this way is natural; even while walking on the street, one will see so many women. However, if one is determined not to live with a woman, even while seeing a woman he will not become lusty. If one is determined not to have sex, he can automatically conquer lusty desires. The example given in this regard is that even if one is hungry, if on a particular day he is determined to observe fasting, he can naturally conquer the disturbances of hunger and thirst.
Source: A.C. Bhaktivedanta Swami Prabhupada (2014 edition), “Srimad Bhagavatam”, Seventh Canto, Chapter 15 – Text 22