I understand the basics of multithreading and synchronization but I cant wrap my head around the way to implement what I need now. Here is the situation:

I have a multi-client server utilizing the Reactor single thread model. I need a thread to sit and wait for connections and accept them which is simple to do and I understand it.

Now I need a thread to handle all the socket reads but I dont understand how to do this because if I create it from the while loop that is accepting connection it would create one for each connection, but I need to seperate it from that thread else it will block.

I also want another thread for actual processing of the commands and data access. Please explain to me how I can accomplish this.

Thank you very much.