代码如下:
using System;
using System.Threading;
class Class1
{
public void Method1()
{
Console.WriteLine("Method1 is the starting point of execution of the thread");
}
public static void Main()
{
Class1 newClass = new Class1();
Thread Thread1 = new Thread(new ThreadStart(newClass.Method1));
Thread1.Name = "Sample Thread";
Thread1.Start();
Console.WriteLine("The execution of Sample Thread has started.");
Thread1.Abort();
}
}单步执行到Console.WriteLine("The execution of Sample Thread has started.");后立即同时输出两行
Method1 is the starting point of execution of the thread
The execution of Sample Thread has started问题是 Console.WriteLine("The execution of Sample Thread has started.");该行代码是怎样实现对method1的调用的呢?请各位赐教
using System;
using System.Threading;
class Class1
{
public void Method1()
{
Console.WriteLine("Method1 is the starting point of execution of the thread");
}
public static void Main()
{
Class1 newClass = new Class1();
Thread Thread1 = new Thread(new ThreadStart(newClass.Method1));
Thread1.Name = "Sample Thread";
Thread1.Start();
Console.WriteLine("The execution of Sample Thread has started.");
Thread1.Abort();
}
}单步执行到Console.WriteLine("The execution of Sample Thread has started.");后立即同时输出两行
Method1 is the starting point of execution of the thread
The execution of Sample Thread has started问题是 Console.WriteLine("The execution of Sample Thread has started.");该行代码是怎样实现对method1的调用的呢?请各位赐教
Console.WriteLine("The execution of Sample Thread has started."); //不关这句的事
Thread1.Start(); 开始执行。