When Brad Koenig divorced and moved from Toledo, Ohio, to Ormond Beach, Fla., in 2017, two of the first things he did were sign up for a yoga class and join a running club.

“The only people I knew in the area were my brother and sister-in-law,” says the former truck driver, 50, who is now a full-time student. “Finding people to work out with was essential to getting my life back on track.”

Koenig did with purpose what many men, including myself, have discovered more incidentally: Exercise can be a great way to form the types of friendships that combat loneliness. The therapists and exercisers I interviewed for this article say that group workouts tend to build stronger bonds than, for example, adjoining cubicles, while enriching men’s lives by introducing them to a wider range of potential acquaintances.

Although loneliness is a condition that can’t be defined and tracked as precisely as diseases are, it appears to be a significant problem in the U.S. A survey by the health service company Cigna of more than 20,000 Americans released last spring found that 46 percent of respondents, who were 18 years and older, said they sometimes or always feel alone, and 27 percent said they rarely or never felt understood by others. An AARP study released in September concluded that 1 in 3 adults 45 or older is lonely.

Research has also found that loneliness is dangerous. “Depression, anxiety, substance abuse — these are often related to loneliness,” says Laura Fredendall, a clinical psychologist in Terre Haute, Ind. And it can have a physical impact: Research on nearly half a million British people found that those who reported more loneliness had a higher rate of heart attacks and death in the seven-year study period.

There is a distinction between being alone and lonely, according to Fredendall. Loneliness is marked by persistent isolation. “It’s feeling like you have no one to relate to, no friendships where you can confide in others,” she says. “You can be in a romantic relationship and have ‘work friends’ but still be quite lonely.”

Men might be especially susceptible, says Mitchell Greene, a clinical and sport psychologist in Haverford, Pa. “Men tend to have fewer friendships than women, and are less likely than women to make social invitations,” he said. “Men’s relationships tend to be more activity-based.”

Enter exercise. Or more precisely, exercising with others.

“I have several male clients who I’ve encouraged to go to group workouts,” Greene says. “It’s not that I’m telling them how to make friends. I’m steering them toward environments in which healthy social ties are more possible.” Or, as Fredendall advises some of her clients: “You need exercise, anyway. Join a group or class instead of going to bars.”

As a middle-aged man who works from home and has a history of depression, I know firsthand the wisdom of this advice. Fifteen years ago, when I moved to Maine from Maryland, I began to purposefully seek out running companions. I wasn’t as fast a runner as in my youth, but that led to a great benefit: a much larger pool of training partners, most of whom I wouldn’t have met otherwise.

In the past year, I’ve run with teens and 70-somethings, and all ages between. I run with men and women, with a variety of family situations. Our backgrounds and professions are similarly diverse. Some are people I see only occasionally for a few friendly miles, while others have become confidants. All enrich my life. At a time when my sedentary contemporaries are more likely to see their worlds shrink, I’ve never had a larger, more eclectic social circle.

How can you convert comrades in sweat into bosom buddies? After all, announcing “I’m here to make friends!” might not go over well in a yoga class in which people are accustomed to a soft “Namaste.”

Some activities have a built-in mechanism for connecting with others. On group runs, for example, I find that conversation flows with an ease I struggle to attain in my sedentary hours. Local running clubs and cycling and ski shops can point you to informal, welcoming gatherings of like-minded people.

Greene has recommended CrossFit to several male clients.

“Many of them grew up playing team sports,” he says. “Now that they’re on their own, without that structure, they’ve sort of lost their way — they’ve stopped taking care of themselves, and they’re not making new friends. CrossFit gives them an element of social encouragement and friendly competition.”

Scott Douglas is a contributing writer for Runner’s World and the author of several books, including “Running Is My Therapy.”