There is a difference between being alone and being lonely. When you are being alone, with noboby else around you, it doesn't mean you're feeling lonely. You can be totally enjoying yourself, doing something or may be just relaxing doing nothing! On the other hand, you may be surrounded by people, but you still feel lonely, because you feel somehow disconnected.
I do feel in order for the others to enjoy one's company, one needs to enjoy his or her own company first. In another words, you have to like yourself first, before you learn to like others.