Statistical mechanics of chain molecules