The Shulchan Aruch (YD 157:1) discusses the issue of when one must (or may) martyr himself, know in Hebrew as קידוש השם - The [Ultimate] Sanctification of God's Name.
If someone threatens your life if you won't break some rule:
- If you are alone (or in the presence of less than ten adult Jews):
- If he is doing so for his own personal benefit:
- If it is one of the "Big Three" (murder, idolatry, illicit sexual relationships):
- If it is other regular sins (even breaking a custom):
- You should break the rule.
- If he is trying to make you break your religion:
- If it is one of the Big Three:
- If it is a regular sin (even breaking a custom):
- You should break the rule, but you may be martyred if you want.
- If you are in public (at least ten adult Jews):
- If he is doing it for his own personal benefit:
- If he is trying to make you break your religion:
- You must be killed for any sin.
- If it is a time of persecution against Jews:
- You must be killed, independent of public/private or type of sin. You must be martyred even for a custom.
It is important to note that one must give away all his money before dying to avoid breaking a negative commandment if you think it will help. Additionally, when I say breaking a negative commandment I mean if doing so involves an action (ie eating pig), but if it involves no action then you need not be killed over it and you can just sit idle. Also, note that in defining public or private, it does not matter as much that the people are there watching you as much as they will obviously hear about what you did (see Shach sk 4 there). Finally I note that women and men are seemingly equal in all aspects of these requirements.
These laws are important to know because if the time comes (chas veshalom) you can't usually CYLOR, and as you say, Jews wouldn't want to give up their lives unnecessarily as we highly value human life.