Training with Lucic during summers has been helpful in Gallagher’s development.

“The coolest part of the summers was just talking to him about their season compared to our season, the little challenges that they faced and things that they know about other players in the league,” Gallagher said. “The more knowledge you have, the better off you are.”

With four years separating Gallagher and Lucic, they were not very close. But that changed last summer after Gallagher’s rookie season in the N.H.L. Now in the middle of a heated rivalry, they had plenty to talk about in the gym.

“I felt like we became a lot better friends and with us both being in the N.H.L.,” said Lucic, who has 15 goals and 21 assists for the Bruins this season. “We had a lot more in common, a lot more to talk about, so our relationship has definitely grown a lot more, especially in this last summer.”

The two acknowledged that hatred for players on the opposite side of the rivalry came up during their many discussions, but they said they tried to limit the antagonism.

“We’ve definitely thrown that around in the gym, and we both just kind of laugh and it’s just one of those things,” Lucic said.

Gallagher said: “You try to stay away from that as much as you can. After games, we send texts back and forth.”