There is a Web server, I want to add clients to streams, but limit their number (for example, no more than 10 streams).
Hence the task: how does a new client come in, create a thread for it, if all threads are busy, then expect the release of any stream.
Now it only occurs to me to create a container (I have not decided on which one to choose) and insert new threads into it, then launch them.
If there are more than 10 threads, then expect the release of one of them.
I also wanted to ask: is it better to kill and create streams (pass a link to this stream to the stream method itself so that it terminates itself and deletes it from the container) or keep them always alive?