BOSTON — As injuries continue to mount for the Boston Bruins, Danton Heinen arrived just in time.

Heinen scored both goals and Anton Khudobin made 36 saves to lift the Bruins to a 2-1 win over the San Jose Sharks on Thursday night.

“It was pretty cool,” Heinen said. “It’s something you dream of your whole life and you just kind of go into shock for a bit.”

Heinen scored for the first time in his career after being recalled from Providence earlier in the day when David Krejci could not suit up for the second straight game. Heinen broke a second-period tie when he tucked a shot inside the left post after Marc-Edouard Vlasic misplayed the puck in the corner at 13:27.

Joe Thornton scored for San Jose, which went 1 for 6 on the power play. The Sharks had one in the final two minutes after Brandon Carlo went off for slashing and got three shots while creating havoc in front of Khudobin but couldn’t capitalize.

“We were pushing and pushing,” Thornton said. “Just couldn’t get another one past him.”

Thornton tied the score at 1 when he scored on the power play and slipped the puck past a screened Khudobin to tie Jari Kurri for 20th all time on the NHL scoring list with 1,398 points.

Khudobin made his third consecutive start for Tuukka Rask, who is recovering from a concussion and is expected to return Saturday.

“Give the goalie credit,” Sharks Coach Peter DeBoer said. “He made some big saves but we have to find a way to score more than one goal.”

Heinen scored short-handed when he knocked in the rebound of David Backes’ shot and beat Martin Jones at 9:41 of the first period.

“The Sharks are a very good team,” Khudobin said. “You have to have a little bit of luck in this league, but the defense did a hell of a job in front of me tonight.”

Jones made 31 saves and had won four straight and only allowed five goals in the last four games.

NOTES: The Sharks moved to 2-2-0 on their five-game trip. … Kevan Miller returned to the lineup after missing one game for Boston. … San Jose has killed 15 straight penalties but has scored only once in its last 16 power plays. … Backes got his first point of the season.