国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

C# 多線程操作樣例

2019-11-17 02:24:59
字體:
來源:轉載
供稿:網友
C# 多線程操作樣例

using System;using System.Threading; //引用多線程namespace ThreadTest{    public class Alpha    {        public void Beta()        {            while (true)            {                Console.WriteLine("Alpha.Beta is running in its own thread.");            }        }    };    public class Simple    {        public static int Main()        {            Console.WriteLine("Thread Start/Stop/Join Sample");            Alpha oAlpha = new Alpha();        //file://這里創建一個線程,使之執行Alpha類的Beta()方法            Thread oThread = new Thread(new ThreadStart(oAlpha.Beta));            oThread.Start();            while (!oThread.IsAlive)                Thread.Sleep(1);            oThread.Abort();            oThread.Join();            Console.WriteLine();            Console.WriteLine("Alpha.Beta has finished");            try            {                Console.WriteLine("Try to restart the Alpha.Beta thread");                oThread.Start();            }            catch (ThreadStateException)            {                Console.Write("ThreadStateException trying to restart Alpha.Beta. ");                Console.WriteLine("Expected since aborted threads cannot be restarted.");                Console.ReadLine();            }            return 0;        }    }}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富锦市| 闸北区| 资兴市| 旬阳县| 虎林市| 中宁县| 泰顺县| 长垣县| 班玛县| 仙居县| 金沙县| 永登县| 和田县| 东明县| 翁源县| 张家界市| 荆门市| 炎陵县| 桂林市| 遵化市| 济阳县| 囊谦县| 孝义市| 兴义市| 碌曲县| 大石桥市| 探索| 镇江市| 靖安县| 嵊泗县| 会昌县| 河津市| 二连浩特市| 合山市| 宜城市| 长白| 霞浦县| 织金县| 昭平县| 马公市| 宁国市|