title: Named pipes: Many clients. How to be prudent with thread creation? Thread Pool?
body: <p><strong>Situation:</strong></p>
  
  <p>I'm am using named pipes on Windows for IPC, using C++.</p>
  
  <p>The server creates a named pipe instance via CreateNamedPipe, and waits for clients to connect via ConnectNamedPipe.</p>
  
  <p>Everytime a client calls CreateFile to access the named pipe, the server creates a thread using CreateThread to service that client. After that, the server reiterates the loop, creating a pipe instance via CreateNamedPipe and listening for the next client via ConnectNamedPipe, etc ...</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>Every client request triggers a CreateThread on the server. If clients come fast and furious, there would be many calls to CreateThread.</p>
  
  <p><strong>Questions:</strong></p>
  
  <p><strong>Q1:</strong> Is it possible to reuse already created threads to service future client requests?
  If this is possible, how should I do this?</p>
  
  <p><strong>Q2:</strong> Would Thread Pool help in this situation?</p>