In what my opinion, you can deal it in three ways.
The usual way: Getting too busy with other things so that you don't have time to overthink. There have been lots of examples already on this thread. In my little experience, this is just trying to repress thoughts, pushing them into deeper and deeper levels of conscience, hoping that they stay buried and don't pop out again.
This will not work. Ever.
But sadly, in this age, we tend to be educated to believe that it works.
The "wishful thinking way": these are a lot of techniques born from the New Age era, when people were convinced that they could "think positive thoughts" to drive "bad thoughts" away. While there are gazillions of methods of self-help who are vaguely reminiscent of self-hypnotism, they have little or no result. In effect, you will be trying to train your mind to think different kinds of thoughts, suppressing the ones you consider "bad". This just leads to stress, specially when one hopes to get quick results (which is hardly ever the case).
While some people publicly report that they have achieved some results with "positive thinking" and its self-help derivatives, to the extent that there are now fields of psychology actively researching this area, I would certainly recommend some caution in applying those methods. If they come from a registered therapist who has been given extensive training in some scientific, peer-reviewed method, then, well, I'd say, go ahead and try. If it's something out of a book bought at a supermarket or an airport, give it a miss.
A typical example: the people behind the incredibly popular
The Secret which Oprah so much adores have cooked-up a method, being used by millions, who allegedly turns everyone following that method into better persons, and they claim that millions have done so. Ironically, the owners to the copyrights on the book and its methods are fighting ugly legal battles in order to make more money, going head over heels about their lawsuits. I imagine that anyone finding "a secret" to have a happy life by changing their mindset with happy, positive thoughts would care little about fighting judicial battles in court... so, well, let's be honest and examine what the people designing those methods are really like, behind their smiling façades and apparently "perfect" life.
The third way: observe the many thoughts carefully. Where do they sprout from? Where do they go once they disappear from your mind? Why do some thoughts come over and over again and cause pain and anxiety? This method is not easy, because it forces us to deal with our own thoughts directly, instead of avoiding them. But instead of repressing thoughts, or forcing ourselves to fill our minds with new thoughts, this method just relies on observing the thoughts very carefully and see where they come from. You might wonder how this helps in any way. Well, I'm not suited to explain the technique well; you need a qualified teacher for that, and one that you can very carefully observe if they apply the technique to themselves as well (i.e. are they balanced, happy, functional people?). The major problem with this technique is that it takes a lot of time to master, and, in these days, we have little patience and demand immediate results. The major advantage is that if you're willing to give it a try, and have a good, experienced teacher, it will work well, and has worked for billions of humans in the past 2,600 years

Qualified teachers of this technique are also readily available these days pretty much everywhere and the technique is usually free to learn, but, since it takes so long, most people give up before they see any results. Which is naturally a pity!
Therapists are able to use a few variants which produce results in a shorter time, e.g. 2-3 years, but after a few months you should feel a bit better about your "overthinking".
Gestalt psychology and therapy produce rather good results in that time frame, by essentially teaching patients to recognise their own thoughts, their causes, and apply antidotes. You might continue to "overthink" but not feel so affected by it (i.e. no stress, anxiety, frustration, and so forth, from the "overthinking" process). Now I'm not a psychologist, so I can't explain how this works, but I would most certainly encourage you to talk to one and strictly follow their methods. I'm also not familiar to the actual training, although it's rather similar to what I'm used to do, just with a Western twist in terms of nomenclature and explanations

In my experience, Gestalt works rather well for those willing to apply it, and the "bad examples" of people who didn't see any effects is also because they gave up too soon and didn't follow the therapy to its conclusion.