Context. Previous works indicate that the frequency ratio of second and first harmonics of kink oscillations tends towards 3 in the case of prominence threads. This is not a straightforward result, so it requires adequate explanation. Aims. We aim to study the magnetohydrodynamic oscillations of longitudinally inhomogeneous prominence threads and to shed light on the problem of the frequency ratio. Methods. The classical Sturm-Liouville problem is used for the threads with longitudinally inhomogeneous plasma density. We show that the spatial variation of total pressure perturbations along the thread is governed by the stationary Schrödinger equation, where the longitudinal inhomogeneity of plasma density stands for the potential energy. The Schrödinger equation appears as the equation of quantum harmonic oscillator for a parabolic profile of plasma density. Consequently, the equation has bounded solutions in terms of Hermite polynomials. Results. Boundary conditions at the thread surface lead to a transcendental dispersion equation with Bessel functions. The thin flux tube approximation of the dispersion equation shows that the frequency of kink waves is proportional to the expression α(2n + 1), where α is the density inhomogeneity parameter, and n the longitudinal mode number. Consequently, the ratio of the frequencies of second and first harmonics tends to 3 in prominence threads. The numerical solution of the dispersion equation shows that the ratio decreases only slightly for thicker tubes in the case of less longitudinal inhomogeneity of the external density, therefore the thin flux tube limit is a good approximation for prominence oscillations. However, stronger longitudinal inhomogeneity of external density may lead to the significant shift in the frequency ratio for wider tubes, and therefore the thin tube approximation may fail. Conclusions. The tendency of frequency ratio of second and first harmonics towards 3 in prominence threads is explained by the analogy of the oscillations with quantum harmonic oscillator, where the density inhomogeneity of the threads plays a role as the potential energy.