We show that the heat exchange between fluid particles and boundary walls can be achieved by controlling the velocity change rate following the particles' collision with a wall in discrete kinetic theory, such as the lattice-gas cellular automata and the lattice Boltzmann method. We derive a relation between the velocity change rate and temperature so that we can control the velocity change rate according to a given temperature boundary condition. This relation enables us to deal with the thermal boundary whose temperature varies along a wall in contrast to the previous works of the lattice-gas cellular automata. In addition, we present simulation results to compare our method to the existing and give an example in a microchannel with a high temperature gradient boundary condition by the lattice-gas cellular automata.