A March 2021 study by the Boston University School of Medicine said, 

"Whereas persistent loneliness is a threat to brain health, psychological resilience following adverse life experiences may explain why transient loneliness is protective in the context of dementia onset,"