传对象(socket)给不同的线程,对像改变后线程中的对象却没有改变,这是何解呢?(王凯明:浅析C#中的套接字编程 中的源码)
poetc 2003-04-07 06:14:02 在socket服务端编程中,
//Form1中
private Socket clientsocket;
private Thread clientservice;
Socket s = listener.AcceptSocket();
this.clientsocket = s;
clientservice = new Thread(new ThreadStart(ServiceClient));
clientservice.Start();
//下面是ServiceClient()
private void ServiceClient()
{
Socket client = clientsocket;
bool keepalive = true;
...
//ServiceClient中的client和this.clientsocket不是指向同一内存地址吗?
那么当有不同的客户端连接后,有不同this.clientsocket,会建不同的线程,但线程中client却不同;
这是何解呢??
下面是文章出处;
程序运行是没问题的。
http://www.aspcool.com/lanmu/browse.asp?page=3&bbsuser=csharp
or
http://www.gbnis.com/searcha.asp?key_word=%C7%B3%CE%F6C%23%D6%D0%B5%C4%CC%D7%BD%D3%D7%D6%B1%E0%B3%CC&search_software=%CB%D1%CB%F7
or
http://www.gbnis.com/read_file.asp?type_id=&id=3236&left=