Ideally they'd be given corporal punishment by perfectly morally upstanding cops. This is cheap, fast, doesn't stop them working and doesn't put them in an environment where they're around lots of hardened convicts.
I leave the problem of getting perfectly upstanding policemen who will not abuse their powers as an exercise to the reader.
Oh, I got this one! Just replace the cops with objective, completely fair AI! That will surely solve all of the problems and definitely hasn't been extensively worried about in science fiction for decades.
I leave the problem of getting perfectly upstanding policemen who will not abuse their powers as an exercise to the reader.