Thinking is a conscious action.
If a thought occurs to you when you are not thinking about that subject the thought is related to then it comes from someone else.
This is not to say that a thought that occurs to you when thinking about a subject and related to that subject cannot come from someone else. It may but also may be from you.
Dreams come from someone else.
The state of having no thoughts is the actual state when you are not thinking at all. This can be proven by how when you are asleep and not dreaming you have no thoughts whatsoever.
And you will need to follow a good path if you are being telepathically attacked by a large group trying to puppet you. This is the only defense one has by oneself against this kind of attack. Hence be good and do all good things also is a good defense and the path to sanity and wisdom.