Today ,we will discuss about small threading program in C#.Net
using System;
using System.Threading;
class ThreadTest
{
public void Run()
{
Console.WriteLine("Run Called");
Thread.Sleep(10000);
}
public static void Main(String[] args)
{
ThreadTest b = new ThreadTest();
Thread t = new Thread(new ThreadStart(b.Run));
t.Start();
Console.WriteLine("Thread 't' started.");
Console.WriteLine("There is no telling when " +
"'Run' will be invoked. ");
t.Join();
Console.WriteLine("Thread 't' has ended.");
}
}
using System.Threading;
class ThreadTest
{
public void Run()
{
Console.WriteLine("Run Called");
Thread.Sleep(10000);
}
public static void Main(String[] args)
{
ThreadTest b = new ThreadTest();
Thread t = new Thread(new ThreadStart(b.Run));
t.Start();
Console.WriteLine("Thread 't' started.");
Console.WriteLine("There is no telling when " +
"'Run' will be invoked. ");
t.Join();
Console.WriteLine("Thread 't' has ended.");
}
}