Iff people knew that if they killed someone they would be put to death, murders might not happen as often from each other of the society discussion

Iff people knew that if they killed someone they would be put to death, murders might not happen as often from each other of the society discussion

What is that called? Does it work? Why or why not?