The first type is called "first boiling." This type is similar to when you shake up a soda bottle and then open the top. If some how a little pressure is released, for example the rock infrastructure of the volcano cracks, the decompression will lower the confining force. When the confining force decreases the vapor pressure of the dissolved volatiles may be able to over come the confining pressure and exsolve from solution. This creates all the bubbles that form when a soda bottle is opened. Second boiling results from when minerals start to crystallize out of the melt. This increases the percent of dissolved gasses in the melt and as a result increases vapor pressure. When vapor pressure exceeds the confining pressure, once again gasses will exsolve from the melt. If the magma is highly viscous the bubbles cannot readily escape and as a result will increase the overall pressure in the magma column. Eventually vapor pressure will exceed the confining pressure of the melt and rock around the magma chamber and the volcano will explode fragmenting the rock and melt and projecting it into the air.
As you can see pressure and the physics behind pressure is what triggers and then drives an explosive eruption.