  A generator of antiproton ($\bar{p}$) in Geant4 has been developed using a
theoretical model with the consideration of near-threshold treatment and used
preliminarily in COMET experiment. The precision of this generator has been
verified by comparing with experimental results taken in CERN (1970) and ITEP
(1994). By implementing this generator into official data analysis framework of
COMET, the yield of $\bar{p}$ in COMET experiment can be evaluated properly.
Background caused by $\bar{p}$ can also be estimated by this generator in
future, which will instruct the design and optimization. Moreover, this
generator can also be used in the simulation of other experiments involving
near-threshold $\bar{p}$ generation.
