I agree with Sabby...
I do have my periods of loneliness as well, and the strange thing is that sometimes they come either after, or in the midst of being very busy or even happy! The other week I was on a hiking trip with friends and I was having such a good time with lovely people, and at some point, as I was sat among everyone else something switched and I dropped, and it was terrible because what do you do when being with friends isn't enough to keep loneliness away?! But I checked myself on the spot, I realised tiredness had started getting to me and that the reason for feeling lonely was that I felt sth good was coming to an end and then I'd lose it forever - if that makes sense. I think in most cases loneliness is related to some kind of loss (not necessarily related to people.) So in the end I managed to just be content feeling a bit detached in the presence of others, in the knowledge that it is temporary and nothing is actually lost.
Sorry, I went a bit off there....I guess what I'm trying to say is that sometimes loneliness has nothing to do with people but something that goes missing or askew and has to do with us alone, fear of something, or losing sight of something important in our own heads..I see this doesn't make as much sense here as it does in my head, but I'm not good at explaining these things..!