"Rav Judah said in the name of Rav: There are four [classes of people] who have to offer thanksgiving: those who have crossed the sea, those who have traversed the wilderness, one who has recovered from an illness, and a prisoner who has been set free." (B. Berachot 54b)