This problem you describe sometimes happens in athletes who do repeated overhand motions as part of their sport. The action of throwing forces the arm out and back in order to “cock” the arm to throw. This can potentially squeeze the ball of the upper arm bone (humerus) against the underside of the rotator cuff tendons, a condition called “internal impingement.”
As this condition develops, the feeling of stiffness initially goes away once you’ve warmed up, and pain felt during the wind up is generally vague. In time, the problem may worsen, causing the shoulder to feel stiff even after a longer warm up. Feelings of vague pain usually become more noticeable around the back part of the shoulder.
Treatment in the early stages involves resting the shoulder for one month followed with a strengthening program for the muscles of the rotator cuff and shoulder blade. Surgery is usually reserved for athletes who’ve had the problem for at least four months and who haven’t gotten better after trying nonsurgical treatments.