Why are condemned prisoners hanged in front of the other inmates? What purpose is this meant to serve?

in 3 sentences

Condemned prisoners are sometimes hanged in front of other inmates to serve as a deterrent and reinforce the seriousness of the punishment. It aims to send a strong message to the remaining inmates about the potential consequences of committing similar crimes. Additionally, witnessing an execution can also invoke a sense of fear and intimidation among the inmate population, potentially leading to better compliance with prison rules and regulations.