当前位置:网站首页>了解下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();}}}
边栏推荐
猜你喜欢

node(三) 模块化

PyCharm使用教程(详细版 - 图文结合)

普林斯顿微积分读本03第二章--编程实现函数图像绘制、三角学回顾

血气方刚的年轻小伙竟去做家政小哥,是怎样成功逆袭转行的

Biotin hydrazide HCl|CAS:66640-86-6|生物素-酰肼盐酸盐

Biotin-EDA|CAS:111790-37-5| Ethylenediamine biotin

Shell becomes canonical and variable

EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network

PyQt5(一) PyQt5安装及配置,从文件夹读取图片并显示,模拟生成素描图像

USACO美国信息学奥赛竞赛12月份开赛,中国学生备赛指南
随机推荐
轴流式水轮机隐私政策
The crawler video crawl tools you get
【开源项目】X-TRACK源码分析
The custom table form
软件测试技术之解析图灵测试离我们还有多远
BGP通过MPLS解决路由黑洞
Mysql Mac版下载安装教程
Business Intelligence Platform BI Business Intelligence Analysis Platform How to Choose the Right Business Intelligence Platform BI
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之一:解题思路
OneNote Tutorial, How to Create More Spaces in OneNote?
Biotin-C6-amine|N-生物素基-1,6-己二胺|CAS:65953-56-2
location对象,navigator对象,history对象学习
C语言基础_结构体
CASA模型、CENTURY模型应用与案例分析
cas:139504-50-0 美登素DM1|Mertansine|
PostgreSQL学习总结(11)—— PostgreSQL 常用的高可用集群方案
Database Plus 的云上之旅:SphereEx 正式开源 ShardingSphere on Cloud 解决方案
cas: 139504-50-0 Maytansine DM1|Mertansine|
What attributes and methods are available for page directives in JSP pages?
PyCharm使用教程(较详细,图+文)