IPhone 4 turns off by itself?
I got an iphone 4 a couple of days ago. I updated it to the latest iOS and everything was working fine. This morning I was on it for a few minutes and put it in my pocket. When I took it back out a couple of minutes later, to my surprise the lock screen would not come up. Assuming it had turned off, I tried to power it on, and it wouldn't. I held down the lock button and the home button together as well, and that didn't work either. Then around lunchtime, i tried to turn it on again and it did. Soon after my lock screen came up, it turned off by itself again. I tried powering it back on and it worked (for once). The phone functioned normally for about 20 minutes. I put it back in my pocket and when I got it back out later, again, it had powered itself off and I could not turn it back on. I just got home and plugged it in to itunes, and it came up saying that my phone is in recovery mode and that it must be restored to factory settings. So now I'm waiting for it to be restored.
My question is, what causes this? And is there any way to prevent it from happening again? It's quite frustrating, and I've seen many posts online related to this, so many people are experiencing the same problem.