Unhappy with his life as a Marine stationed in California, Terence Tyler posed a question three years ago on Twitter: “is it normal to want to kill ALL of ur coworkers?”

Struggling with depression, he left the Marines and recently started working at a supermarket in New Jersey.

On Friday morning, Tyler shot two co-workers and himself, police said. The 23-year-old, clad in desert camouflage gear, opened fire at a Pathmark store in Old Bridge Township, authorities said.

Authorities are investigating his motive, but family members said Tyler was discharged from the Marines two years ago after suffering from depression and had never gotten over his mother’s death about five years ago.

Authorities said Tyler left his job as an overnight clerk at the Pathmark about 3:30 a.m. He drove off and returned to the store shortly afterward with a handgun and an assault rifle, Middlesex County Prosecutor Bruce Kaplan said. About a dozen workers were in the closed store, putting new prices into a computer.

Tyler fired more than 16 rounds from his rifle — shooting at an employee standing outside and blowing out windows, authorities said. He shot at five other workers in an aisle, killing Cristina LoBrutto, 18, and Bryan Breen, 24, the prosecutor said.

Tyler, who began working at the supermarket less than two weeks ago, then drew his handgun and killed himself, Kaplan said.

Several ammunition magazines were recovered along with the rifle and a .45-caliber handgun, he said.

“I do not believe that they were specifically targeted,” Kaplan said of the two victims. “I believe everybody in the store was a target.”

John Niccollai, president of a foodworkers union, said many of the employees escaped harm when an assistant manager directed them toward a back door.

Breen and LoBrutto were both cashiers. They normally worked day shifts, but pulled overnight shifts every few weeks to put in new price changes, Niccollai said. Tyler began work for Pathmark Aug. 20 as a night clerk, stocking shelves.

Pathmark worker Miranda Miranda said she steered clear of Tyler.

“The way he looked at me, he gave me an uneasy vibe,” she said.

Miranda usually worked the overnight shift Thursday but said LoBrutto agreed to work the shift for her a few weeks ago. “That could’ve been me,” Miranda said.

Tyler was discharged from the Marines in 2010, nearly two years in the service at Twentynine Palms, Calif., according to the Marines. The infantryman from New York City never served overseas, said Marine spokeswoman Capt. Kendra Motz. She wouldn’t comment on the circumstances of his discharge.

Tyler’s Twitter account, which has a photograph identified by family members as Tyler, interspersed posts about hating Marine life, expressions of violence, and his take on football, movies, women and other interests.

“smh is it normal to want to kill ALL of ur coworkers?Maybe but I’m actually in a position where I can,smh,” he wrote in June 2009, using the handle (at)Tylerbkstyle and the abbreviation “smh” for “shaking my head.”

Tyler tweeted months later about killing.

“I’m starting to see why plp go on killin sprees,” he wrote. And these (obscenity) are reeeeeeally pushin my kill everyone I see button.”

At the top of Tyler’s Facebook page was the motto: “Be optimistic. All the people you hate are going to eventually die.”

Christopher Dyson, Tyler’s uncle, said Tyler left the Marines after suffering from depression. A cousin said Tyler had been hospitalized.

Tyler, who also lived in San Diego, left California in June for New Jersey, where he lived with his sister and uncle.

“He was a quiet cat, you know?” said Dyson, who works at the store and helped Tyler get a job there.

His cousin, Shanteya Dyson, said Tyler had not been the same since his mother died of cancer.

“That was his best friend. He was always a quiet guy. But he got more quiet. He really didn’t speak at all. He was just blank,” Dyson said.