110,535
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int x = 0;int y = 0;
var t1 = new Thread1();
Thread t11 = new Thread(() => t1.hanshu(ref x,ref y));
t11.Start();
for (int s= 0;s<100;s++)
{
Console.WriteLine("x=" + x + " y=" + y);
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Thread1
{
public void hanshu(ref int x,ref int y)
{
for (int s = 0; s < 100; s++)
{
x++;
}
for (int s = 0; s < 100; s++)
{
y++;
}
}
}
}