📄 th3.cs
字号:
using System;
using System.Threading;
namespace th3
{
class ThTest3
{
static void Main(string[] args)
{
MyData num=new MyData();
Thread t1=new Thread(new ThreadStart(num.Run));
Thread t2=new Thread(new ThreadStart(num.Run));
t1.Start();
t2.Start();
for (int i=0;i<10;i++)
{
Thread.Sleep(1000);
num.TestEquals();
}
}
}
class MyData
{
private int x=0,y=0;
public void Inc()
{
x++;y++;
}
public void TestEquals()
{
Console.WriteLine (x+","+y+":"+(x==y));
}
public void Run()
{
while(true)
Inc();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -