In the new study, the researchers drew the records of replies for 315,059 of the men and women, most of whom had completed their questionnaires about 13 years before. They checked answers and categorized people according to their reported exercise habits and whether and how they had altered over the years.

Some of the men and women said they had been unwavering in their workout routines, spending about as many — or few — hours exercising in midlife as when they had been teenagers.

Others had been active when young but tailed off as adults, remaining mostly sedentary during middle age. And a few had exercised often as teenagers and young adults, slowed or stopped as adults, but returned to regular exercise later in life.

Finally, the researchers checked the National Death Index for deaths and their causes among the participants in the years since they had joined the health study and compared the risks of dying among the different groups. (They controlled for body mass, smoking and other health factors.)

Not surprisingly, those men and women who had been sedentary throughout their lives were the most likely now to have died, particularly from heart disease.

But those people who always had been active, exercising consistently for a few hours a week, were about 30 to 35 percent less likely to have passed away from any cause and about 40 percent less likely to have died of a heart attack than the consistently inactive people.

More buoying, people who had stopped exercising for a decade or two but begun again during their 40s or 50s, working out then for a few hours a week, shared the same relative protection against premature death as the people who always had exercised.