Can't say I know exactly what you're going through, but I've been through a phase relative to this one. I've got major ADHD, so I take meds that help me focus. When I have nothing to focus on, I start mindlessly thinking. It's suicidal.
Don't give yourself time to think. I know that sounds counterproductive, but mindless thinking results in thoughts that are often self-deprecating. Sometimes people need this type of stuff, but it sounds like you've been mindlessly thinking for far too long with no real goal. So, if you want to stop this mindless thinking, you've got to start doing the things that you really won't want to do:
Fill up your schedule. Be busy. Be social.
You sitting at home not being social and playing video games? Get a fucking Nintendo Switch or some portable shit and play video games at your local bar. Doesn't matter if nobody talks to you, it's a start.
You got hobbies? I'm not talking like, "Lol, I smoke weed" or "I go out and drink"... I'm talking like, productive shit. Running, working out, playing sports, playing eSports... just something that gives you a challenge that you actually want to tackle. If you've got those types of hobbies, throw yourself at them.
Don't got any hobbies? You've got all the time in the fucking world to find one. You don't want to research? You don't have to. Just open up your browser, type in some keywords related to your research, open up a couple of tabs, and let it sit. Open up Microsoft Word, type the cover to your thesis, and write the first sentence.
The hardest part about anything is starting it.
You've achieved all your goals? That's fine. But don't be selfish, get married and make some fucking kids. Have your spouse and your kids teach you new things.
Teach others what you've learned. Learn from those who you teach. Argue with them. Play devil's advocate.
Just don't start thinking without a reason to think.