电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

使用ThreadStart委托来衍生三个新线程


发布日期:2022/12/1
 

//使用ThreadStart委托来衍生三个新线程

using System;

using SystemThreading;

namespace ThreadStartSampleCS

{

class Program

{

static void Main()

{

Thread newThread;

ThreadStart threadMethod = new ThreadStart(DoWork);

for (int counter = ; counter < ; counter++)

{

ConsoleWriteLine(Starting Thread {} counter);

newThread = new Thread(threadMethod);

newThreadName = counterToString();

newThreadStart();

}

ConsoleReadLine();

}

static void DoWork()

{

for (int counter = ; counter < ; counter++)

{

ConsoleWriteLine(Thread {}: iteration {} ThreadCurrentThreadName counter);

ThreadSleep();

}

}

}

}

上一篇:在Windows应用程序中支持拖拽的TreeView控件

下一篇:VB动态调用自己的ActiveX DLL