There is a saying about the practice: "Don't be afraid of a thought arising, just be afraid of noticing it too late." It's not such a terrible thing for thoughts to arise. The problem is when you're not aware of them. If you realize it as soon as a thought arises, then it doesn't matter. It will help you to work harder. If there were no thoughts arising at all, you would already have a pure mind and you wouldn't need to practice. People who have never practiced may know about their wandering thoughts but can do nothing to stop them.
When you are practicing hard, whatever thought comes up you have the power to just sweep it away. To sweep means to ignore, not to dislike or to resist the thought. How else could you sweep it away? If you resist it with something else, that something else is also a thought. If I wanted to get rid of Tom, and got Dick to do the job, after Tom left I would still be stuck with Dick. No matter how many people I find to get the other one out, there would always be one left. If you get involved with feelings after the thought is already gone, thinking, "What bad luck. I hope it doesn't come up again, " your mind will definitely be scattered. Then you begin to think, "I'm hopelessly sunk in wandering thoughts. I'll just give up meditating." If you work like this, the wandering thoughts don't get swept away, they just accumulate. This is because you haven't put down the state of mind which gave rise to the thoughts in the first place.