Fix a race condition in TcpServerThread

Signed-off-by: Balint Kovacs <blint@blint.hu>