Why did the man thank the bartender?
The man had the hiccups. He asked the bartender for a glass of water to cure the hiccups. However, the bartender instead scared the hiccups out of the man by pointing a gun at him. Since the bartender cured his hiccups, the man thanked him and left.