It's simple, actually. You store the user name and the thread they're subscribed to somewhere. Let's suppose it's a database.
Now, when someone <b>posts a new message</b> to any given thread, your code would have to look up from the db everyone who has subscribed and mail the new message to them - the time consumng part would come with the posting. Which is what people are used to, and besides, it doesn't take all that much time.