The demons cannot know our thoughts but they conclude on what we think. They have a lot of experience and they can sense the presence God’s grace. In fact this is what burns them.
When we pray, the demons attempt to hinder the prayer by sending continuously a lot of thoughts, not because they know our thoughts but because they see God’s grace which showers us.
That’s why they try to feed our mind on something else in order to distract it, because when the mind, – our ultimate attention – is concentrated on something else it loses it’s communication and union with God and thus loses God’s grace and henceforth our minds are darkened.
So, particularly during the moment of prayer we must not think anything else except the words of prayer. It doesn’t matter how pious the invading thought may be, we must ignore it, keep the mind inside our hearts and solely concentrate on the words of prayer.
Based on Saint Arsenios the Great, Saint John of the Ladder, Elder Joseph the Hesychast