Home >Backend Development >C#.Net Tutorial >Detailed introduction to the difference between C# threads and thread pools

Detailed introduction to the difference between C# threads and thread pools

黄舟
黄舟Original
2017-03-20 13:30:562817browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn