When things change temperature, they chance size. When one side of an object heats up a lot, and the other side doesn’t, the hotter/bigger side tries to tear the colder/smaller side apart. This can form cracks and cause shattering. More stretchy materials, or materials that are strong in tension (harder to pull apart) tend to put up well with sudden temperature changes. This is why pouring ice water in a warm (normal) glass will often crack it, but doing something similar in pyrex or steel will be fine.
Latest Answers