Simultaneous generation of a proton beam and terahertz radiation in high-intensity laser and thin-foil interaction