C#控制台应用程序中的多线程示例 [英] Multithread samples in C# console application

查看:918
本文介绍了C#控制台应用程序中的多线程示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请给我一些示例,以在控制台应用程序的C#代码中调用无数个多线程.

谢谢,
Senthil

Please give me some samples for calling innumerous Multiple threads in C# code of Console application.

Thanks,
Senthil

推荐答案

首先,不要简单地要求代码,这不是Q& A论坛旨在...的内容.

无论如何,.NET提供了几个类和机制来创建和使用多个线程,您可以在MSDN上找到很多示例.您必须选择适合您需要的课程...

例如:任务并行库线程类线程池类 ...
First of all, do not simply demand code, that''s not what the Q&A forum is intended for...

Anyway, .NET offers several classes and mechanisms to create and use multiple threads and you can find lots of examples at MSDN. You have to choose which class fits your needs...

For example: Task Parallel library, BackgroundWorker class, Thread class, ThreadPool class...


首先创建线程.
firstly make threads.
ThreadStart t1=new ThreadStart(Threadname1);
ThreadStart t2=new ThreadStart(Threadname2);
ThreadStart t3=new ThreadStart(Threadname3);
Thread th1=new Thread(t1);
Thread th2=new Thread(t2);
Thread th3=new Thread(t3;
th1.Priority=ThreadPriority.High;
th2.Priority=ThreadPriority.;
th3.Priority=ThreadPriority.normal;
th1.Start();
th2.Start();
th3.Start();


这篇关于C#控制台应用程序中的多线程示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆