而(真)阻止

CaT*_*aTx 1 while-loop

我在网上看到了这段代码.但是,我无法理解while(true)在此代码中阻塞是如何发生的:

private void ListenForClients()
{
  this.tcpListener.Start();

  while (true)
  {
    //blocks until a client has connected to the server
    TcpClient client = this.tcpListener.AcceptTcpClient();

    //create a thread to handle communication
    //with connected client
    Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientComm));
    clientThread.Start(client);
  }
}
Run Code Online (Sandbox Code Playgroud)

有谁可以向我解释一下?我知道使用while(true)+破坏条件,但这件事超出了我的意思.

Fls*_*Zen 5

AcceptTcpClient什么阻止.将while (true)只会无休止地循环下去,直到进程终止时,线程被中断,或者抛出异常.