Creation of thread: (Unlike java, there is no need to inherit the Thread class)
TcpClient tc = tListener.AcceptTcpClient(); CThreadServer ctserver = new CThreadServer(tc); Thread t = new Thread(new ThreadStart(ctserver.AcceptImageFile)); t.IsBackground = true; t.Start();
Creation of thread pool
TcpClient tc = tListener.AcceptTcpClient(); CThreadServer ctserver = new CThreadServer(tc); //Thread t = new Thread(new ThreadStart(ctserver.AcceptImageFile)); //t.IsBackground = true; //t.Start(); ThreadPool.QueueUserWorkItem(new WaitCallback(ctserver.AcceptImageFile));
But here AcceptImageFile and thread creation The AcceptImageFile in is different
In thread creation, it is AcceptImageFile();
In thread pool creation, it is AcceptImageFile(Object o);The Object o here is Must join.
The above is the detailed content of Detailed introduction to the difference between C# threads and thread pools. For more information, please follow other related articles on the PHP Chinese website!