当前位置:网站首页>了解下C# 多线程
了解下C# 多线程
2022-08-02 08:17:00 【nginx】
using System;using System.Threading;namespace MultithreadingApplication{class ThreadCreationProgram{public static void CallToChildThread(){try{Console.WriteLine("Child thread starts");// 计数到 10for (int counter = 0; counter <= 10; counter++){Thread.Sleep(500);Console.WriteLine(counter);}Console.WriteLine("Child Thread Completed");}catch (ThreadAbortException e){Console.WriteLine("Thread Abort Exception");}finally{Console.WriteLine("Couldn't catch the Thread Exception");}}static void Main(string[] args){ThreadStart childref = new ThreadStart(CallToChildThread);Console.WriteLine("In Main: Creating the Child thread");Thread childThread = new Thread(childref);childThread.Start();// 停止主线程一段时间Thread.Sleep(2000);// 现在中止子线程Console.WriteLine("In Main: Aborting the Child thread");childThread.Abort();Console.ReadKey();}}}
边栏推荐
- Write a small game in C (three chess)
- MySQL 中 count() 和 count(1) 有什么区别?哪个性能最好?
- Postman download localization of installation and use
- Database triggers and transactions
- R language plotly visualization: plotly visualizes the scatter plot of the actual value of the regression model and the predicted value of the regression, analyzes the prediction performance of the re
- Three types of [OC learning notes] Block
- [ansible] playbook explains the execution steps in combination with the project
- 52. [Bool type input any non-0 value is not 1 version reason]
- node(三) 模块化
- Biotin - LC - Hydrazide | CAS: 109276-34-8 | Biotin - LC - Hydrazide
猜你喜欢

A young man with strong blood and energy actually became a housekeeper. How did he successfully turn around and change careers?
![[ansible] playbook explains the execution steps in combination with the project](/img/fe/82b8562075fef33490d5aae7e809f5.png)
[ansible] playbook explains the execution steps in combination with the project

小康股份更名赛力斯,如何走出一条高端产品的“丝绸之路”?

PyCharm usage tutorial (detailed version - graphic and text combination)

(Note)阿克西斯ACASIS DT-3608双盘位硬盘阵列盒RAID设置

houdini 求出曲线的法向 切线以及副法线

工程师如何对待开源 --- 一个老工程师的肺腑之言

mysql 中 in 的用法

Postman download localization of installation and use

IO process thread -> process -> day4
随机推荐
小说里的编程 【连载之二十二】元宇宙里月亮弯弯
Postman download localization of installation and use
prometheus监控mysql_galera集群
Biotin-C6-amine|N-生物素基-1,6-己二胺|CAS:65953-56-2
nodejs 简介
(Note) AXIS ACASIS DT-3608 Dual-bay Hard Disk Array Box RAID Setting
力扣:第 304 场周赛
USACO美国信息学奥赛竞赛12月份开赛,中国学生备赛指南
Biotin - LC - Hydrazide | CAS: 109276-34-8 | Biotin - LC - Hydrazide
Installation and use of pnpm
编程与哲学(2)——输出是为了更好的输入
OneNote Tutorial, How to Create More Spaces in OneNote?
商业智能平台BI 商业智能分析平台 如何选择合适的商业智能平台BI
C语言基础_结构体
近期在SLAM建图和定位方面的进展
EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network
【论文阅读】Distilling the Knowledge in a Neural Network
IO进程线程->进程->day4
location对象,navigator对象,history对象学习
day_05 time 模块