Optimization of the communication between main the thread thread and TCP connection threads.