The Buddha describes two types of bhikkhus based on how they deal with thoughts of sensuality, ill-will, and harming while walking, standing, sitting, and lying down, and which one is capable of reaching the highest awakening.

Cara sutta - Walking

Toleration of harmful thoughts

"Bhikkhus, if while a bhikkhu is walking, a thought of sensuality, a thought of ill-will or a thought of harming arises, and if that bhikkhu tolerates it, does not abandon it, dispel it, eliminate it, or bring it to an end, even while walking, such a bhikkhu is called 'unmotivated, without concern, constantly slack, and weak in effort.'

Bhikkhus, if while a bhikkhu is standing, a thought of sensuality, a thought of ill-will or a thought of harming arises, and if that bhikkhu tolerates it, does not abandon it, dispel it, eliminate it, or bring it to an end, even while standing, such a bhikkhu is called 'unmotivated, without concern, constantly slack, and weak in effort.'

Similarly, bhikkhus, if while a bhikkhu is sitting, a thought of sensuality, a thought of ill-will or a thought of harming arises, and if that bhikkhu tolerates it, does not abandon it, dispel it, eliminate it, or bring it to an end, even while sitting, such a bhikkhu is called 'unmotivated, without concern, constantly slack, and weak in effort.'

Similarly, bhikkhus, if while a bhikkhu is lying down but awake, a thought of sensuality, a thought of ill-will or a thought of harming arises, and if that bhikkhu tolerates it, does not abandon it, dispel it, eliminate it, or bring it to an end, even while lying down, such a bhikkhu is called 'unmotivated, without concern, constantly slack, and weak in effort.'

Abandonment of harmful thoughts

Bhikkhus, if while a bhikkhu is walking, a thought of sensuality, a thought of ill-will, or a thought of harming arises, and if that bhikkhu does not tolerate it but abandons it, dispels it, eliminates it, and brings it to an end, even while walking, such a bhikkhu is called 'with continuous effort, with concern, continuously with energy aroused, and determined.'

Bhikkhus, if while a bhikkhu is standing, a thought of sensuality, a thought of ill-will, or a thought of harming arises, and if that bhikkhu does not tolerate it but abandons it, dispels it, eliminates it, and brings it to an end, even while standing, such a bhikkhu is called 'with continuous effort, with concern, continuously with energy aroused, and determined.'

Similarly, bhikkhus, if while a bhikkhu is sitting, a thought of sensuality, a thought of ill-will, or a thought of harming arises, and if that bhikkhu does not tolerate it but abandons it, dispels it, eliminates it, and brings it to an end, even while sitting, such a bhikkhu is called 'with continuous effort, with concern, continuously with energy aroused, and determined.'

Likewise, bhikkhus, if while a bhikkhu is lying down but awake, a thought of sensuality, a thought of ill-will, or a thought of harming arises, and if that bhikkhu does not tolerate it but abandons it, dispels it, eliminates it, and brings it to an end, even while lying down, such a bhikkhu is called 'with continuous effort, with concern, continuously with energy aroused, and determined.'

Verse

Whether walking or standing, sitting or lying down; Whoever nurtures harmful thoughts, connected to the household life
Such a one is on the wrong path, infatuated with defilements; That kind of bhikkhu is incapable, of reaching the highest awakening.
But one who, whether walking or standing, sitting or lying down; Has calmed their thoughts, delighting in the stilling of thoughts; That kind of bhikkhu is capable, of reaching the highest awakening."

A more detailed discourse on the theme of dealing with thoughts is in MN 19, and one on shaping of thoughts is in MN 20.