Specs...? Make and Model of the computer would be nice
Have you added/removed any hardware or software prior to the problem?
edit: may be a virus, I've had experiences when a worm would cause my computer to restart like you described..... try booting into
Safe Mode with Networking, update your anti-virus defintions and run a scan......Download, Install, update, and run
Malwarebytes too(it's free
)
To get into safe mode with networking: shutdown your computer, turn on, tap F8 key, when Advanced Options appear, select "Safe Mode With Networking"
Please do, inspect the inside of the computer. Verify that the cpu fan is spinning when turned on, and see if there is a LOT of dust. Look at the heat sink of the CPU. If there is a lot of dust, I would get yourself a can of compressed air, pronto!