Whiny little kids

My oldest son did this when he was 7 or 8, old enough to understand when I put my foot down and told him “I cannot hear you when you whine like that” and I followed through. It was hard but I ignored him. I do not remember how long it took, but he stopped it.