The cookoff of explosives is of great concern for the safety assurance of explosive devices in storage, transportation and handling. It may occur in the situation that explosive devices are subjected to the external heating stimuli such as fire or high-temperature surrounding. In order to gain ever-increasing knowledge toward the cookoff explosion of explosives, we establish numerical program to predict the cookoff explosion of explosive in a metal container. The computational formulation and methods are given in detail. The thermal decomposition and temperature variation in the interior of explosive were found corresponding to several typical external heating conditions. The results demonstrate that the method is beneficial to the future study on this subject.