HE was 39 and thought he was in decent shape. But when Eric Goodman, an information technologist from Stamford, Conn., tried to run a mile on a treadmill, he could barely make it without feeling as if he were coughing up a lung.

If Mr. Goodman were younger, he might have joined a gym or played soccer, as he did in college. Instead he started doing triathlons. In a year, he lost 17 pounds and added 6 pounds of muscle, and is now able to run one mile in 6 minutes 30 seconds. He says he feels like a 20-year-old again.

“I’m not looking for my fountain of youth, but I am trying to stay as young as I can for as long I can,” said Mr. Goodman, now 40. “I didn’t realize how bad of shape I was in.”

Mr. Goodman is part of a generation of athletic, type-A men who are entering middle age and trying to hold on to their youth through triathlons — a race that combines swimming, biking and running. The sport has exploded by 51 percent since 2007, according to the Sporting Goods Manufacturers Association, and men in their 40s are one of the fastest growing segments in the sport, accounting for one-third of the 1.2 million triathletes.