class Program
{
static void Main(string[] args)
{
Console.WriteLine("线程已开启:");
Thread workerThread = new Thread(new ThreadStart(WorkerMethod));
workerThread.Start();
}
static void WorkerMethod()
{
for (int i = 0; i < 20; i++)
{
Console.WriteLine("打印出的数字为:[{0}]",DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
Thread.Sleep(60000);
}
}
}
本文展示了一个使用C#进行线程编程的例子。通过创建并启动一个后台工作线程,每隔一分钟向控制台输出当前时间及计数。该示例有助于理解如何在C#中实现基本的线程操作。
3648

被折叠的 条评论
为什么被折叠?



