Temperature is the degree of the hotness or coldness of a body. When two bodies are placed in contact to each other, the heat flows from higher body temperature to lower body temperature. It can explained like there are two containers having water at different levels. Of we connect both the containers by a tube attaching at the bottom of both the containers the water flows from higher level to the lower level.
Temperature may be defined as the thermal state of the body, which decides the direction of flow of heat energy from one body to another when they are placed in the thermal contact to each other. The temperature of a body is the measurement of average kinetic energy of the molecules of that body. When a body is heated, its molecules move faster. Their average kinetic energy increases. This will increase the temperature of the body. Temperature is an effect of heat as we supply heat to any system, the temperature increases and as we take out heat from any system the temperature of the system decreases. In the thermodynamics the temperature follows from the zeroth law of thermodynamics.
A system is said to be in the state of thermodynamic or thermal equilibrium if the macroscopic variables describing the thermodynamic state of the system do not change with respect to time. For example, consider a gas inside a closed rigid container completely insulated from the outer surroundings, if the temperature, pressure, volume and the mass of the system remains constant, they do not change with time, such system is called is in the state of thermal equilibrium. A system is in the state of thermal equilibrium if it posses the following three types of the equilibrium.
(i) Mechanical equilibrium: There is no unbalanced force in its interior or between the system and the surroundings.
(ii) Thermal equilibrium: All parts of the system and the surroundings are at the same temperature.
(iii) Chemical equilibrium: The system does not undergo any spontaneous change in its internal structure due to chemical reactions such as diffusion, etc.