A court heard the group of youngsters, aged between 12 and 16, were frightened by the comments made by Rabbnawaz Ali.
Leeds Crown Court heard Ali made the threats on November 12, 2016, as the group were returning from Leeds city centre to the barracks in Sheepscar after selling poppies in Leeds city centre.
Ali approached the group and said: “Where are you off next lads, Iraq?
“Better be careful because me and by Isis brothers will kill you all. Your day will come?”
The court heard some of the boys were left shocked by the comments and went inside the barracks before the instructor challenged Ali and threatened to call police.
Ali then said to the instructor: “Your time will come. We are going to bomb your compound.”
Ali was arrested over the incident after he carried out an arson attack at a betting shop on January 18 last year.
The court heard he went into a William Hills bookies on Roundhay Road, Harehills,and became aggressive towards a member of staff after losing £60 on a roulette machine.
Ali demanded his money back before grabbing the assistant by his tie.
He left and the member of staff locked the door but Ali kicked in a glass panel to get back inside.
He then set fire to waste paper bins and tipped over the gambling machines.
Alun Jones, prosecuting, said people inside the shop were frightened as the room began to fill with smoke.
Police arrived and Ali made abusive comments to officers.
He said: “If I behead a police officer will I get deported.”
Ali, of Spencer Place, Chapeltown, Leeds, pleaded guilty to racially aggravated threatening behaviour, arson, assault and criminal damage.
The court heard Ali had been diagnosed as a paranoid schizophrenic.
A psychiatrist told the court Ali had not been engaging with his mental health team and refused to take anti-psychotic medication at the time of the offending.
Kenton Sergeant, mitigating, said Ali’s religious beliefs were “within cultural norms”.
Ali was made the subject of an indefinite hospital order under the Mental Health Act, combined with a 19-month prison sentence.
Recorder Christopher Smith said Ali would be detained in hospital but he could be transferred to a prison if it was no longer considered necessary.
He said: “It is important to recognise the context in which you made those comments.
“They were army cadets and, I have no doubt, hold those positions with a sense of pride.
“Since the murder of Lee Rigby in May 2013, members of the armed forces have been on a heightened state of alert because of the dangers of wearing a uniform in public.
“Young people such as these are in a similar position.
“Inflammatory comments fuel hatred and instil a state of fear.”