Daemon Threads, thread count, and total started thread count

前端 未结 2 1720
攒了一身酷
攒了一身酷 2021-02-20 17:18

I have a simple code for a multi-threaded echo server in Java (it returns whatever received back to the clients). I\'m profiling various resources of the server including the th

2条回答
  •  面向向阳花
    2021-02-20 18:07

    I'm not sure what you use to receive those connections, but usually frameworks that handle TCP connections non-blocking like Netty use a master thread to listen to the port and a thread pool to handle incomming connections. This means it will at least open 2 threads for the incomming connection if the thread-pool is limited to 1 thread.

    See this example from the netty page, where 2 NioEventLoopGroups are used while bootstrapping the server.

    The 2 threads are necessary to not block incoming traffic.

提交回复
热议问题