public class Student
{
public string name { get; set; }
public string sex { get; set; }
}
public static void Show01()
{
int r = new Random().Next(3, 4);
System.Threading.Thread.Sleep(r * 1000);
Console.WriteLine("线程01 不带参数,不带返回值");
}
public static void Show02(int a,int b)
{
int r = new Random().Next(3, 4);
System.Threading.Thread.Sleep(r * 1000);
Console.WriteLine("线程02 带参数,不带返回值");
}
public static Student Show03(int a, int b)
{
int r = new Random().Next(3, 4);
System.Threading.Thread.Sleep(r * 1000);
Console.WriteLine("线程03 带参数, 带返回值");
a = b;
return new Student() { name="张三", sex="男" };
}
static void Main(string[] args)
{
Task.Run(() => Show01());
Task.Run(() => Show02(1,2));
var s= Task.Run(() => Show03(1, 4));
Console.WriteLine("Hello World!");
Console.WriteLine("姓名:"+s.Result.name+"; 性别:"+s.Result.sex );
Console.ReadLine();
}