By
using ThreadStart delegate, you can specify the method that executes on a
Thread.
Program.cs
using System.Threading; using System; namespace ThreadingTutorial { class HelloWorld { static void Main(string[] args) { Thread t1 = new Thread(new ThreadStart(print)); t1.Name = "Thread1"; t1.Start(); } public static void print() { Console.WriteLine(Thread.CurrentThread.Name + " Executing"); } } }
Output
Thread1
Executing
No comments:
Post a Comment