WindowsならWaitForMultipleObjects()
UNIX系ならselect()かpoll()