technically it doesn't communicate with thousands of connections, just one. your cable modem connects you to your internet service provider (ISP), using cable frequencies over your normal coax lines for communication, setting up a connection with the ISP. then they basically act as a gateway to the internet.
all your modem does is connect and communicate with your ISP. different modems work in different ways (cable, DSL, standard dial-up) but once they're connected and transmitting data they all do essentially the same thing. all the communication with different hosts on the internet is done by your computer, which sends data over the modem connection to the ISP to tell them what information it wants, and from what host/website/etc. the modem is little more than a dumb box that takes the messages your computer sends and forwards them to your ISP in the right format.
for more detailed information on how things work after that, you should try searching google for "how the internet works" or something like that. don't limit it to cable modems only, as I said they are only a small part of the picture.