System.Threading.Thread的使用及傳遞參數等總結

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;函數

namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
//線程啓動One()
Thread t = new Thread(() => One());
t.Start();spa

//線程啓動One(object p) 方法一(傳遞參數)
Thread tt = new Thread(() => One("mang"));
tt.Start();線程

//線程啓動Two(object p) 方法二(傳遞參數)
Thread ttt = new Thread(new ParameterizedThreadStart(Two));
ttt.Start("mangmang");
Console.ReadLine();string

//構造函數
//new Thread(ThreadStart start) 初始化Thread類的新實例
//start 類型:System.Threading.ThreadStart
// ThreadStart委託,它表示此線程開始執行時要調用的方法。
}it

static void One()
{
Console.WriteLine("One");
}io

static void One(object p)
{
Console.WriteLine("One's parameter is " + p.ToString());
}class

static void Two(object p)
{
Console.WriteLine("Two's parameter is " + p.ToString());
}
}
}object

相關文章
相關標籤/搜索