If the Hermit Kingdom implodes, China is going to be the recipient of tens of thousands of starving NKorean refugees crossing their border, and they really don’t want to see that happen.
China has significant internal security issues, not the least of which are approx. 200k disaffected former People’s Liberation Army (Chinese Army) officers, which could potentially form the heart of a serious insurgency movement. Along with tensions surrounding groups like the Uighurs and the mass displacement of peasants throughout the country, China has a very good reason to maintain the status quo ante in NKorea.
I’m sure it doesn’t hurt the Chinese cause to tie down valuable US military resources (there are some 30k US troops in SKorea), and see what sort of response the US offers to Kim Jong-il’s goading, but there are other reasons than the obvious at play here.