When connect pendrive pc autometacally restarted

If this happens only with the one drive, the drive is bad, has some type of electrical short. If this happens to all of the USB drives you try, reset the PC BIOS to default (unplug PC, locate the BIOS jumpter on the motherboard, move it to the reset position for a few seconds then back.)