A metal contains a large number of free electrons. They move at random within the metal with different velocities. But at ordinary temperatures, they cannot leave the surface due to attractive forces between the electrons and the positive ions. If the metal is heated, the kinetic energy of the electrons increases.
Above a certain temperature, a large number of electrons get energy greater than the work function of the metal and the thermionic emission begins. When a metal surface is coated with oxides of barium, strontium etc., the work function is reduced.