There are two variables, both adjustable. Loneliness is eliminated is when that delta is small or zero.
If you’re an introvert and don’t desire social connection and have none, you’re fine. But being in a situation that reminds you of your lack sometimes creates that desire, which creates that delta.
Likewise, if you’re an extrovert, you desire lots of social connection and when it falls below what you actually have you feel sad.
We can’t always control the amount of social connection we get due to circumstances, but we can sometimes control the amount of desire we have by avoiding triggers that remind us.