When a metal is heated to the sort of high temperatures where it begins to glow (red) some electrons escape from the metal. This is known as the thermionic effect and was discovered accidently by Edison several years before the discovery that cathode rays were in fact electrons. Its a natural phenomenon that if a metal is heated that many of its electrons might gain sufficient energy to escape from the metal. This would leave the metal with an overall positive charge which would attract back the escaping electrons.
Consequently the escaping electrons are decelerated and having lost
energy, tend to form a "space charge" near the heated metal. By placing
a second metal near the space charge and making it more positive than
the heated metal, electrons from the space charge are attracted to it
and so a current flows. This is the basis of the thermionic diode. The
diode consisted therefore of two metal plates with a voltage across them
enlosed in a glass tube that was partially evacuated. The heating of the
cathode made the release of electrons easy and enabled a current to flow
through the remaining gas in the tube. When de Forrest introduced a
third electrode (called a grid) in 1907, a triode was formed and this
was the first modern electronic component that ultimately paved the way
for radio, television and computers, etc.