In this paper, a four-dimensional (4D) dynamic cooperative path planning algorithm for multiple unmanned aerial vehicles (UAVs) is proposed, in which the cooperative time variables of UAVs, as well as conflict and threat avoidance, are considered. The algorithm proposed in this paper uses a hierarchical framework that is divided into a 4D cooperative planning layer and a local threat avoidance planning layer. In the cooperative planning layer, the proposed algorithm, named dynamic priority rapidly exploring random trees (DPRRT*), would be used for the 4D cooperative path planning of all UAVs involved in a given task. We first designed a heuristic prioritization strategy in the DPRRT* algorithm to rank all UAVs to improve the efficiency of cooperative planning. Then, the improved RRT* algorithm with the 4D coordination cost function was used to plan the 4D coordination path for each UAV. Whenever the environment changes dynamically (i.e., sudden static or moving threats), the proposed heuristic artificial potential field algorithm (HAPF) in the local threat avoidance planning layer is used to plan the local collision avoidance path. After completing local obstacle avoidance planning, the DPRRT* of the 4D cooperative planning layer is again called upon for path replanning to finally realize 4D cooperative path planning for all UAVs. The simulation and comparison experiments prove the feasibility, efficiency, and robustness of the proposed algorithm.