On the iMac (21.5-inch, Late 2009) I noticed that the built in wireless would go out after a few minutes of operation and thereafter would reboot. Having tried all other suggestions here and other sites and opening up iMac to clean and check boards I found that turning off the Apple wifi resolved the repetitive rebooting. I installed a wifi adapter card and solved this iMac’s problem.
Also found the Apple fan control very useful to keep temperatures down.
Hope this helps.