【C#多线程】 动态创建多个线程后 需要关闭其中某个线程的解决实例

上传者: hewusheng10 | 上传时间: 2019-07-31 19:19:00 | 文件大小: 22KB | 文件类型: RAR
#>【C#多线程】 动态创建多个线程后 需要关闭其中某个线程的解决实例。 using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { List listThread = new List(5); Thread thread = null; for (int i = 0; i < 5; i++) { thread = new Thread(ThreadMethod); thread.Name = "Thread" + i; Console.WriteLine("创建 Thread" + i); listThread.Add(thread); thread.Start(i); Thread.Sleep(i * 100); } //关闭指定线程 foreach (Thread tempThread in listThread) { if (tempThread.Name == "Thread3") { Console.WriteLine(tempThread.Name + " 线程已关闭"); tempThread.Abort(); } } Console.ReadLine(); } private static void ThreadMethod(object t) { Thread.Sleep(1500); Console.WriteLine(String.Format("我是 Thread{0}", t)); } } } for (int i = 0; i < 5; i++) { Thread thread = new Thread(test) ; thread.Start(); } 如何关闭其中的一个线程呢? 请下载解决方案。 呵呵,这个实例10分值的买, 觉得好的话就评个分吧,评分后会返回你11分 (一定要评分,光评论是不返分的)

文件下载

资源详情

[{"title":"( 13 个子文件 22KB ) 【C#多线程】 动态创建多个线程后 需要关闭其中某个线程的解决实例","children":[{"title":"ConsoleApplication1","children":[{"title":"ConsoleApplication1.suo <span style='color:#111;'> 13.50KB </span>","children":null,"spread":false},{"title":"ConsoleApplication1","children":[{"title":"Program.cs <span style='color:#111;'> 1.19KB </span>","children":null,"spread":false},{"title":"ConsoleApplication1.csproj <span style='color:#111;'> 2.16KB </span>","children":null,"spread":false},{"title":"obj","children":[{"title":"x86","children":[{"title":"Debug","children":[{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 4.98KB </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"ConsoleApplication1.exe <span style='color:#111;'> 5.50KB </span>","children":null,"spread":false},{"title":"ConsoleApplication1.csproj.FileListAbsolute.txt <span style='color:#111;'> 594B </span>","children":null,"spread":false},{"title":"ConsoleApplication1.pdb <span style='color:#111;'> 13.50KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":"bin","children":[{"title":"Debug","children":[{"title":"ConsoleApplication1.vshost.exe.manifest <span style='color:#111;'> 490B </span>","children":null,"spread":false},{"title":"ConsoleApplication1.exe <span style='color:#111;'> 5.50KB </span>","children":null,"spread":false},{"title":"ConsoleApplication1.pdb <span style='color:#111;'> 13.50KB </span>","children":null,"spread":false},{"title":"ConsoleApplication1.vshost.exe <span style='color:#111;'> 11.34KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"Properties","children":[{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.36KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"ConsoleApplication1.sln <span style='color:#111;'> 899B </span>","children":null,"spread":false}],"spread":true}],"spread":true}]

评论信息

  • 南郭未末 :
    这也值11分,很晕。不过谢谢提供思路
    2019-09-05
  • shenshen2011 :
    非常有用。多谢啦
    2019-08-01
  • abcdef1111111 :
    谢谢分享,用来参考
    2019-03-01
  • gzhoney :
    很好,谢谢楼主!
    2018-09-18
  • cqg116 :
    很好,看好非常棒。非常有用。多谢啦
    2017-09-29

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明