On one occasion the Blessed One was living at Savatthi in Jeta's Grove, Anathapindika's Park. There he addressed the bhikkhus: "Bhikkhus, before my enlightenment, while I was still only an un-enlightened Bodhisatta, it occurred to me: 'Suppose that I divide my thoughts into two classes.' Then I set on one side thoughts of sensual desire, thoughts of ill will, and thoughts of cruelty and I set on the other side thoughts of renunciation, thoughts of non-ill will, and thoughts of non-cruelty."
"As I abided thus, diligent, ardent, and resolute, a thought of sensual desire arose in me. I understood thus: 'This thought of sensual desire has arisen in me. This leads to my own affliction, to others' affliction, and affliction of both; it obstructs wisdom, causes difficulties and leads away from Nibbana.' When I considered: 'This leads to my own affliction, others' affliction and affliction of both,' it subsided in me; when I considered: 'This obstructs wisdom, causes difficulties, and leads away from Nibbana,' it subsided in me. Thus whenever a thought of sensual desire arose in me, I abandoned it and did away with it. "
"Similarly as I abided thus, diligent, ardent, and resolute, a thought of ill will arose in me.. .a thought of cruelty arose in me. I understood thus: 'This thought of ill will/cruelty has arisen in me. This leads to my own affliction, to others' affliction, and to both; it obstructs wisdom, causes difficulties, and leads away from Nibbana.' When I considered thus.. .it subsided in me. Whenever a thought of cruelty arose in me, I abandoned it and did away with it."
"Bhikkhus, whatever a bhikkhu frequently thinks and ponders upon, that will become the inclination of his mind. If he frequently thinks and ponders upon thoughts of sensual desire, he has abandoned the thought of renunciation to cultivate the thought of sensual desire and then his mind inclines to thoughts of sensual desire. Similarly if he frequently thinks and ponders upon thoughts of ill will...upon thoughts of cruelty, he has abandoned the thought of non-cruelty to cultivate the thought of cruelty, and then his mind inclines to thoughts of cruelty. Just like in autumn as in the last month of the rainy season, when the crops thicken, a cowherd would guard his cows by constantly tapping and poking them to check and curb them. Why is that? Because he sees that he could be imprisoned, fined, or blamed if he let them stray into the crops. So too I saw in unwholesome states danger, degradation, and defilement, and in wholesome states the blessing of renunciation, the aspect of cleansing."
"As I abided thus, diligent, ardent, and resolute, a thought of renunciation arose in me. I understood thus: 'This thought of renunciation does not lead to my own affliction, or to others' affliction, or affliction of both; it aids wisdom, does not cause difficulties, and leads to Nibbana. If I think and ponder upon this thought, I see nothing to fear from it. But with excessive thinking and pondering I might tire my body, the mind becomes disturbed and become far from concentration.' So I steadied my mind internally, quieted it, brought it to singleness, and concentrated it. Why is that? So that my mind should not be disturbed."
"As I abided thus, diligent, ardent, and resolute, a thought of non-ill will arose in me...a thought of non-cruelty arose in me. I understood thus: "This thought of non ill-will/non-cruelty has arisen in me and it does not lead to my own affliction, or to others' affliction, or affliction of both; it aids wisdom, does not cause difficulties, and leads to Nibbana. If I think and ponder upon this thought, I see nothing to fear from it. But with excessive thinking and pondering I might tire my body, the mind becomes disturbed and it is far from concentration.' So I steadied my mind internally and concentrated it so that my mind should not be disturbed. "
"Bhikkhus, whatever a bhikkhu frequently thinks and ponders upon, that will become the inclination of his mind. If he frequently thinks and ponders upon thoughts of renunciation, he has abandoned the thought of sensual desire to cultivate the thought of renunciation, and then his mind inclines to thoughts of renunciation. If he frequently thinks and ponders upon thoughts of non-ill will...upon thoughts of non-cruelty, he has abandoned the thought of cruelty to cultivate the thought of noncruelty, and then his mind inclines to thoughts of non-cruelty. Similarly just like in the last month of the hot season, when all the crops have been brought inside the villages, a cowherd would guard his cows while staying at the root of a tree or out in the open, since he needs only to be mindful that the cows are there; so too there was need for me only to be mindful that those states were there."
"Tireless energy was aroused in me and unremitting mindfulness was established, my body was tranquil and untroubled, my mind concentrated and unified. Quite secluded from sensual pleasures, secluded from unwholesome states, I entered upon and abided in the first jhana....I directly knew: 'Birth is destroyed, the holy life has been lived, what had to be done has been done, there is no more coming to any state of being.' This was the third true knowledge attained by me in the third watch of the night. Ignorance was banished and true knowledge arose, darkness was banished and light arose, as happens in one who abides diligent, ardent, and resolute. "
"Suppose, bhikkhus, that in a wooded range there was a low-lying land near which a large herd of deer lived. Then a man who desired for their ruin and he closed off the safe and good path that led to their happiness and he opened up a false path, and he put out a decoy and set up a dummy so that the large herd of deer might later come upon calamity and disaster. But another man came desiring for their good, welfare, and protection, and he reopened the safe and good path that led to their happiness, and he closed off the false path, and he removed the decoy and destroyed the dummy, so that the large herd of deer might later come to growth, increase, and fulfillment. "
"Bhikkhus, I have given this simile in order to convey a meaning. 'The great low-lying marsh' refers to sensual pleasures. 'The large herd of deer' refers to beings. 'The man desiring their ruin, harm, and bondage' refers to Mara the Evil One. 'The false path' refers to the wrong eightfold path, that is: wrong view, wrong intention, wrong speech, wrong action, wrong livelihood, wrong effort, wrong mindfulness, and wrong concentration. 'The decoy' refers to delight and lust. 'The dummy' refers to ignorance. 'The man desiring their good, welfare, and protection' refers to the Tathagata, accomplished and fully enlightened. 'The safe and good path that led to their happiness' refers to the Noble Eightfold Path, that is: right view, right intention, right speech, right action, right livelihood, right effort, right mindfulness, and right concentration.
"So, bhikkhus, the safe and good path that leads to happiness has been reopened by me, the wrong path has been closed off, the lust removed, the ignorance destroyed. What should be done for his disciples out of compassion by a teacher who seeks their welfare and has compassion for them, that I have done for you, bhikkhus. There are these roots of trees, these empty huts. Meditate, bhikkhus, do not delay or else you will regret it later. This is my instruction to you."
That is what the Blessed one said. The bhikkhus were satisfied and delighted in the Blessed One's words.
In summary, buddha talked about 2 thoughts: 1. Thoughts of Sensuality, Thoughts of ill will, Thoughts of harm: leads to own affliction, to others' affliction, affliction of both; obstructs wisdom, causes difficulties and leads away from Nibbana. 2. Thoughts of Non-sensuality, Thoughts of non-ill will (loving-kindness), Thoughts of Non-harm (compassion) : it does not lead to my own affliction, to others' affliction, affliction of both; aids wisdom, does not cause difficulties, and leads to Nibbana.
When the first type of thoughts arises, he advised us to reflect on the danger of this thoughts and get rid of them.He advised the monks to follow the noble eightfold path in order to abandon cravings and ignorance; this will result in insights and wisdom and leads to nibbana.
References: 1. www.accesstoinsight.org 2. https://suttacentral.net/ 3. The middle length discourses of the Buddha (Bhikkhu Bodhi)