  In this paper we have considered the holographic dark energy and studied it's
cosmology and thermodynamics. We have analysed the generalized second law (GSL)
of thermodynamics in a flat universe consists of interacting dark energy and
dark matter. We did the analysis both under thermal equilibrium and
non-equilibrium conditions. If the apparent horizon is taken as the boundary of
the universe, we have shown that the rate of change of the total entropy of the
universe is proportional to $(1+q)^2,$ which in fact shows that the GSL is
valid at the apparent horizon irrespective of the sign of $q,$ the deceleration
parameter. Hence for any form of dark energy the apparent horizon can be
considered as a perfect thermodynamic boundary of the universe. We made a
confirmation of this conclusion by using the holographic dark energy. When
event horizon is taken as the boundary, we found that the GSL is only partially
satisfied. The analysis under non-equilibrium conditions revealed that the GSL
is satisfied if the dark energy temperature is greater than the temperature of
dark matter.
