Personally I am into gambling not to win a jackpot or earn huge money, I gamble for fun just to earn some extra funds thus I only gamble with small amount of money the amount of money I can afford to lose, I am a soccer fan and enthusiast so my area of interest is on soccer betting I bet with small odds of 2.00 to 4.00 thus staking small money to earn a double digit profit, of course it has nothing to do with my loneliness because most matches are played during weekends except occasionally during midweek when there are UCL matches therefore being lonely can never prompt me to engage in gambling activities there are other things that can keep me busy like learning how to trade, reading articles etc.
That's the right way to gamble, when you gamble for entertainment, you won't be pressured to gamble when you don't want to. Gambling for entertainment always makes gambling fun and that's how gambling is meant to be and not a must do activity. Loneliness shouldn't make you start gambling as that'll make you addicted very quickly due to been lonely sometimes during the day. When you're feeling lonely, go out and do others things and not gambling.
Any individual that's the type that gets lonely very quickly, he can learn how to trade like you wrote or learn how to use his time to make money from the internet. When you're making money you can't be lonely and you'll not have to gamble for money as many gambling are doing which is what's making them to lose money, when you're already making money from other sources that are consistent then you can gambling for entertainment and you will enjoy it as well