The invention provides a method for efficiently and diversifying the synthesis of uracil and thymine derivatives. In this method, iodouracil and thymine compounds, electrophiles (halogenated alkanes or brominated aromatic compounds), nucleophiles (alkenes, alkynes, borates, etc.), palladium catalysts, norbornene derivatized Dissolve the substance and alkali (potassium carbonate) together in an organic solvent (1,4-dioxane or ethylene glycol dimethyl ether), then stir and react at 50-150°C, and separate and purify after the reaction, which can be efficient and economical , Green synthesis of polysubstituted uracil and thymine compounds. The method has mild conditions, good substrate universality and high yield, and the prepared 2-pyridones and uracils are widely used in the fields of medicinal chemistry and organic chemistry. In addition, a method for synthesizing key intermediates of anti-HIV drugs is also provided, which improves step economy.