using System;
using System.Threading;
namespace Demo
{
class F{
static string Answer()
{
Console.WriteLine("continue counting?y/n");
string s;
s = Console.ReadLine();
return s;
}
public static void CountMain()
{
int c;
c = 0;
while( Answer()=="y" )
{
c++;
Console.WriteLine("current count number in count main is {0}",c);
}
}
public static void CountChild()
{
int c;
c = 0;
while( Answer()=="y" )
{
c++;
Console.WriteLine("current count number in count child is {0}",c);
}
}
}
class Program{
public static void Main(string[] args)
{
Thread th = new Thread(F.CountMain);
th.Start();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
关于thread一个没搞好的例子
最新推荐文章于 2023-05-12 00:17:18 发布