MONCTON, N.B. -- A New Brunswick man who threatened during a conversation at a farmer's market in May to kill police officers was sentenced Tuesday in Moncton to a nine-month conditional sentence.

Jasper John Stam posted comments about a couple of weeks later that sympathized with the actions of a man later convicted of murdering three RCMP officers.

It was those comments that led the farmer's market vendor and his girlfriend who heard the threat to report them to police, the Crown said.

Judge Anne Dugas-Horsman of the provincial court agreed with a joint submission from the Crown and defence that Stam, 24, should serve the first three months of his sentence under house arrest and the remaining time on probation.

Stam pleaded guilty June 18 to uttering the threat. Court heard Tuesday that Stam said he would kill police and he wished them dead.

His sentence includes a condition that Stam have no contact with Justin Bourque, who will be sentenced next month for the fatal shootings of the three Mounties on June 4.

Stam, who was surrounded by family members in court, declined comment at sentencing and outside court.

Crown lawyer Mario Cormier presented an agreed statement of facts in court saying that Bourque and Stam had known each other for about 14 years, but they weren't close friends or confidantes.

"They were acquaintances, they knew each other," Cormier said.

He also said that Stam had similar "anti-police and anti-establishment views" as Bourque.

He said Stam's threat occurred at the Dieppe farmer's market at some point between May 10 and May 18, after Stam joined in a conversation between a vendor and the vendor's girlfriend.

Cormier said Stam's comments were reported to the RCMP after the fatal shootings of constables Fabrice Georges Gevaudan, Douglas James Larche and Dave Joseph Ross on June 4. Stam was arrested and charged four days later.

"(The complainants) saw some disturbing comments on his Facebook and this is what led them to make the complaint to the RCMP after the fact," said the Crown lawyer.

He said the postings were sympathetic to Bourque and "what had occurred on June 4." He said they were offensive but didn't specify in court what they said.

Defence lawyer Jean Cormier said outside court that he felt the threat likely never would have been reported if the shootings hadn't occurred and if Stam hadn't posted them on social media.

"The whole traumatic experience of the City of Moncton ... certainly was a factor here," he said of the sentence.

The defence lawyer said Stam and Bourque were friends as boys, but the relationship had lapsed and the last time Stam saw Bourque was briefly at a wedding in February.

He said his client hadn't known Bourque as a violent person and had rushed to his defence on social media during the shootings.

"His initial reaction after the events was to be supportive of a former friend. That reaction was unfortunate in this instance but can be understood," said the defence counsel.

"Sometimes you support friends who shouldn't be supported."

Cormier said his client is a law-abiding citizen who is not violent, has no interest in firearms and never had broke the law before.

The judge noted Stam had no prior record, had spent 11 days in custody and holds down a steady job.

"His pre-sentence report shows a supportive family and a strong work ethic ... which makes it all the more difficult to explain such violent words towards those in authority," Dugas-Horsman said.

During his house arrest, Stam will be allowed to leave home for work, medical appointments and religious ceremonies.