Let me explain the physics of this. As materials, be they glass, ceramic, metal, liquids, etc., heat or cool, they expand or shrink. It is this quality that creates the explosions. Glass is an insulator. It doesn't accept or transfer heat readily. When you take glass that is very hot, or very cold, and immerse it into an environment that forces rapid temperature change (placing a hot casserole dish onto a water covered counter top where the water rapidly cools the material that it touches) the glass that is forced to rapidly change temperature contracts. But the heat isn't dissipated from the whole container. Only the outermost skin of the glass is rapidly cooled. Glass and ceramic have very little elasticity and the rapidly cooling surface contracts much faster than the iner layer of the material, creating huge stress until the glass shatters.
Think of a bi-metallic strip. It is made of two metals, with different expansion rates, welded together. When they are heated, one strip expands faster than the other one. This causes the strip to bend as one piece of metal pulls on the other for the length of the strip. That's what makes an electric toaster stop toasting. The strip finally bends enough so that it trips a latch that turns off the toaster and releases a spring loaded bread holder. That same bending action is forced onto a glass or ceramic dish when it is very hot or cold, and is subject to extreme temperature change. The outside surface expands or contracts too quickly and tries to bend the whole dish. That force becomes strong enough to shatter the glass.
Pyrex used to be made from a special formulation of glass that transfered heat throughout the whole of the container much more quickly, and thus prevented the thermal shock problem. But now, they just use tempered glass as it's cheaper.
Believe it or not, in extreme cases, cast iron can be made to shatter in the same way that ceramics or glass can shatter from thermal shock. But it takes extreme temperatures to do it. I have heard of it happening though.
Be careful with any pot or pan, no matter what it's made of. I have seen the bottom of my stainless steel pots expand and suddenly warp inwards when placed on too high a heat, with little liquid in them. This caused a loud bang when the pan bottom popped upward and threw water into the air. The bottom got bigger, but the sides didn't change thier circumferance, and the only direction the metal had to go was up, suddenly and with violent consequences. Fortunately I wasn't very close and didn't get hit with hot water.
Know a bit about your cooking tools and you will be safe. All pots, pans, and cooking vessels have strengths, and weaknesses. It's best to knowsomething about the properties of the tools you use so that you get safe, and effective results with them.
Seeeeeeeya; Goodweed of the North