Here is more about the cavity magnetron. Curiously, the first magnetron (not yet using a cavity resonator) was invented by Albert W. Hull of the General Electric Research Laboratory in the early 1920s as a means, by using a magnetic field instead of electrostatic repulsion, to control the flow of electrons, to circumvent Lee de Forest’s patents on vacuum tubes with a control grid. It was only later, in 1929, that Japanese researchers discovered such a device was able to operate at microwave frequencies where conventional vacuum tubes were inefficient.
In 1940, John Randall and Harry Boot of the University of Birmingham, England combined the idea of magnetic control of electron flow with a tuned cavity resonator to create a compact, high power device able to produce short pulses ideal for radar applications. The invention was shared with the United States, and contributed mightily to defeating the U-boat threat in the Battle of the Atlantic and defending Britain against bombing attacks by Germany. It was one of the most carefully guarded technological secrets of World War II.
Today, it is estimated that more than a billion cavity magnetrons have been produced, mostly for microwave ovens.