📄 class1.cs
字号:
using System;
using System.Threading;
namespace StopThread
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
static int i=0;
static bool state;
static void Main(string[] args)
{
Thread t=new Thread(new ThreadStart(a));
t.Start();
state=true;
while(t.IsAlive)
{
if(i>=50)
{
StopT();
}
}
}
static void a()
{
while(state)
{
Console.WriteLine(++i);
//Thread.Sleep(10);
}
Console.WriteLine("Thread Final");
}
static void StopT()
{
state=false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -