In the present paper, an efficient method of solving the main problem of thermodynamics of homogeneous spaces is presented. The method is based on the formalism of the noncommutative harmonic analysis relying on the method of orbits of coassociated representation. In the present work, the formula is derived that allows one to construct effectively the density matrix and the statistical sum in space of any arbitrary generally noncompact nonunimodular Lie group. To illustrate the method, an example is given of exact calculation of the statistical sum and density matrix in the Riemannian space of the noncompact Lie group with left-invariant metric.