It is said that a life is a sequence of choices. It is your choice whether to give thanks or to complain. In the Bible, there are people who chose to give thanks in the dangerous situation of being cast into fire for not worshipping idols. There is also a man who gave thanks though he had been whipped and imprisoned for delivering the gospel. As the result, those who had been cast into fire didn't get burned and the prison gate was opened by an earthquake to set the prisoner free. Those who choose to give thanks, regardless of circumstances, can move the heart of God and experience miracles.