Here are several suggestions for helping your young child learn to share:
Be a role model. If you share and take turns with your child, he will experience how nice it is to have someone share with him, and will learn to do the same thing with others.
Try to let your child have enough space to play beside another child, but make room for her own toys and activities. When children are very young, it's a good idea to have duplicate toys to make everybody happy. Allow your child to think of a toy as "mine, mine, mine!" but also praise your child when she lets someone else take a turn. Describe how the other child feels when she shares, such as, "Johnny is so happy you gave him a turn with the ball."
Be a guide. If your child wants a toy another child has, help him find some other interesting toy or activity in the meantime, to help him learn to wait.
Be patient. Know that it takes time for children to be ready to share, so don't expect your child to be too generous too soon. And certainly don't punish her for not sharing or taking turns. You want sharing to be a happy experience - not something your child feels forced to do.
At about three years old, help your child sort it out with other children if an argument develops over a toy. This will give him the skills to eventually work things out himself.
And finally, until you feel your child can handle them, avoid situations with too many children. They can be overwhelming if a child is in the middle of an "all mine" stage.