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

黄舟
Release: 2017-03-20 13:30:56
Original
2784 people have browsed it

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();
Copy after login

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));
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template