ThreadStart myThreadStart = new ThreadStart(ThreadFunction);
Thread myThread = new Thread(myThreadStart );
myThread.Start();
public void ThreadFunction(){ Console.WriteLine("我开启了一个线程!Id是" + Thread.CurrentThread.ManagedThreadId);
}
Thread myThread = new Thread(new ThreadStart(ThreadFunction));
myThread.Start();
new Thread(new ThreadStart(ThreadFunction)).Start();
Thread myThread = new Thread(() => Console.WriteLine("我开启了一个线程!Id是" + Thread.CurrentThread.ManagedThreadId));
myThread.Start();
new Thread(()=>{
Console.WriteLine("我开启了一个线程!Id是" + Thread.CurrentThread.ManagedThreadId);
}).Start();
Thread myThread = new Thread(()=>{
Console.WriteLine("我开启了一个线程!Id是" + Thread.CurrentThread.ManagedThreadId);
});
myThread.Start();
Thread myThread = new Thread(() =>
{
ThreadFunction();
});
myThread.Start();
Thread myThread = new Thread(new ThreadStart(() => ThreadFunction(3, 4)));
myThread.Start();
public void ThreadFunction(int a, int b){ Console.WriteLine("我开启了一个线程!Id是" + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("a+b=" + (a+b));
}
Thread myThread = new Thread(ThreadFunction);
myThread .Start("test.jpeg");
public void ThreadFunction(object filename)
{
Console.WriteLine("开始上传" + filename);
Thread.Sleep(1000);
Console.WriteLine("上传完成");
}