Sunday, 3 December 2017

C# Program to Illustrate the Concept of Passing Parameter for Thread


Code:

using System;
using System.Threading;
public class pgm
{
    public static void Main()
    {
        Thread newThread = new Thread(pgm.work1);
        newThread.Start(20);
        pgm p = new pgm();
        newThread = new Thread(p.work2);
        newThread.Start("Instance");
        Console.ReadLine();
    }
    public static void work1(object data)
    {
        Console.WriteLine("Static Thread Procedure : Data ='{0}'",data);
    }
    public void work2(object data)
    {
        Console.WriteLine("Instance Thread Procedure : Data ='{0}'", data);
    }
}


Output:

Static Thread Procedure : Data = '20'
Instance Thread Procedure : Data = 'Instance'


More C# Programs:


















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...