This depends on the gambler in question, if a responsible gambler is lonely, I don't think that he will see gambling as something that will free him from loneliness. Why I said this is because a discipline gamble will have his time limit that he uses to gamble and as long he is gambling on his lonely time, he will stop gambling was his time limited is over.
It is a gambler that cannot control his gambling activities that will use his loneliness as an excuse to game all through and we all know that gamblers that cannot discipline themselves will end up becoming an addict through any means, either by chasing his loss or passing away time with gambling. If you are lonely, go and chill with your friends or go to the cinema and enjoy yourself but not with gambling.
I think it is right to set the record straight that gambling in itself is addictive. Especially when you are already deeply rooted to gambling or you do it for fun and it will become a part of you. So since it is highly addictive, then loneliness can ignite your urge to gamble some more.
I have friends back then that were into online betting of sports odds, like football. And will go to the extent of saving their pocket money to be able to afford some money they can use to stake odds and it's really that addictive and terrible. Now, since it's not everyone that have the mental capacity to hold disappointments and tensions, this could lead to mental issues for some people.