Thundereggs are a very special and unique rock whose scientific name is lithophysae and only form in very special kinds of lavas called perlite which is a form of rhyolite and a close relative of obsidian. 

Many people would think that the interesting rind and pocket which forms a Thunderegg would form as the same time as the filling, but really there can be millions of years between the formation of the pocket in the rhyolite and the filling of the pocket with cool materials like agate and jasper