  A fast-mode shock can form in the front of reconnection outflows and has been
suggested as a promising site for particle acceleration in solar flares. Recent
development of magnetic reconnection has shown that numerous plasmoids can be
produced in a large-scale current layer. Here we investigate the dynamical
modulation of electron acceleration in the looptop region when plasmoids
intermittently arrive at the shock by combining magnetohydrodynamics
simulations with a particle kinetic model. As plasmoids interact with the
shock, the looptop region exhibits various compressible structures that
modulate the production of energetic electrons. The energetic electron
population varies rapidly in both time and space. The number of 5$-$10 keV
electrons correlates well with the area with compression, while that of $>$50
keV electrons shows good correlation with strong compression area but only
moderate correlation with shock parameters. We further examine the impacts of
the first plasmoid, which marks the transition from a quasi-steady shock front
to a distorted and dynamical shock. The number of energetic electrons is
reduced by $\sim 20\%$ at 15$-$25 keV and nearly 40\% for 25$-$50 keV, while
the number of 5$-$10 keV electrons increases. In addition, the electron energy
spectrum above 10 keV evolves softer with time. We also find double or even
multiple distinct sources can develop in the looptop region when the plasmoids
move across the shock. Our simulations have strong implications to the
interpretation of nonthermal looptop sources, as well as the commonly observed
fast temporal variations in flare emissions, including the quasi-periodic
pulsations.
