A prison inmate who wrote a series of letters from his cell threatening to kill 10 people, including prison staff and police officers, and then have sex with their corpses has been jailed for 45 years.

Richard Ford, 38, was given one of the longest ever non-life sentences for someone who has not killed or caused serious injury after the judge said he represented a grave danger to the public.

Ford wrote a series of letters from his cell at Nottingham prison in which he identified people – including prison officers, a fellow inmate, a district judge, a police officer and a former partner – he wanted to kill and then have sex with their dead bodies.

At the time Ford was serving a 30-month jail sentence for possession of a knife in a public place.

Ford, 38, of no fixed address, admitted 10 charges of making a threat to kill on different dates in January 2015 and asked to be kept in prison for the rest of his life.

The court was told he had been assessed by a number of psychiatrists but there was no recommendation he receive hospital treatment.

The judge Michael Heath, passing sentence at Lincoln crown court on Monday, described the long jail term as highly unusual and said the case had caused him “very considerable anxiety”.

He said Ford was “plainly dangerous” and had told psychiatrists that he still wanted to harm people.

“You say you don’t want to be released from prison because you don’t feel that you can stop yourself from acting upon your sadistic urges. Those urges are to kill and have sexual intercourse with the corpses of those whom you kill.

“You have made it clear to me that you do not wish to be released from prison. If you are released you think you will get drunk, obtain a weapon and kill.”

Heath said the maximum sentence for an offence of making a threat to kill was 10 years’ imprisonment.

“I cannot impose a sentence of imprisonment for life, although you have been anxious to let me know that you don’t want to be released. There is no medical recommendation before me for a medical disposal, so I cannot legally make a hospital order.”

The judge said he was trying to balance the need to protect and the need to ensure that the sentence was not “wholly disproportionate to your criminality”.

“Achieving both of these aims in this case is impossible. I realise that the overall length of the sentences I am going to pass is highly unusual and may be controversial, but I pass them because I deem them to be the only adequate way to protect the public in your case.”

The judge imposed five consecutive nine-year jail terms with a further five sentences of nine years to run concurrently, making a total of 45 years.

Jonathan Straw, prosecuting, said that in January last year Ford handed a letter to a prison officer saying he wanted to have sex with a fellow prisoner and kill him and wanted to have sex with a prison officer and beat him up.

A few days later Ford handed over four further notes to prison staff giving details of people he wanted to kill.

The court was told that Ford had convictions in 2002 and 2003 for indecency offences. He was then convicted in 2011, 2013 and 2014 for offences of possession of a knife in a public place.

Isabelle Wilson, in mitigation, said Ford had spent most of the last 14 years in prison.

She said: “He does not wish to be released. He does not feel he is safe to be released. He does wish to receive treatment either in a prison or in a hospital setting.

“The thoughts he discusses are concerning, but at least he is willing to speak about those thoughts openly.”