the behavior is called stereotype behavior; boredom is one factor but often, like horse cribbing and dogs licking their paws constantly, it becomes habit... a sort of 'mental masturbation' for a better term i.e. the behavior gives a sort of pleasure, anything from release of anxiety to stretching muscles, so the reward for the behavior is the feeling good, so to feel good, the animal does the behavior, and the reinforcement is built in the cycle... so is whirling around in dogs, goats rub their foreheads, or suck their own teats (had one do that, for a three months we didnt understand where all her milk was going, til we caught her in action)...
round fences break some habits, changing toys in the habitat help, making a 'search for food' game set up works (like for dogs, the KONG is a well known toy, but for monkeys, food treats are hidden in bamboo sticks, under things, elelphants have to lift and move logs to get to a treat, scattering food makes the animal work and search for it... so take part of the food and place in harder to get places, or scatter it, and the bird will have to search to find)...
after a change in schedule or stress there is more fence pacing, paw licking, fence chewing, just like humans smoke cigarettes or chew gum or nibble their hair more under stress, as the action relieves the stress (pressure)...
yes, i had emus, and ostriches, and various and sundry mammals and reptiles... not farmed, but as petting zoo so we had to provide habitats for them...
bina