Thread类有4种不同的构造:
主题(ParameterizedThreadStart)
主题(的ThreadStart)
Thread(ParameterizedThreadStart,Int32)
Thread(ThreadStart,Int32)
但为什么以下代码有效?
class Program {
static void Main(string[] args) {
Thread t = new Thread(count2);
t.Start();
count1();
Console.ReadLine();
}
public static void count1() {
for (int i = 0; i < 10; i++) {
Console.WriteLine("count1: " + i);
}
}
public static void count2() {
for (int i = 0; i < 10; i++) {
Console.WriteLine("count2: " + i);
}
}
}
我没有传递Thread构造的ParameterizedThreadStart-delegate或ThreadStart-delegate。我只传递一个普通的count2方法。但为什么会这样呢?