Skip to content

Instantly share code, notes, and snippets.

@luisdeol
Created November 12, 2017 13:33
Show Gist options
  • Save luisdeol/1ce0adea30a706ceda8932952ebdfa27 to your computer and use it in GitHub Desktop.
Save luisdeol/1ce0adea30a706ceda8932952ebdfa27 to your computer and use it in GitHub Desktop.
Using Parametrized ThreadStart
namespace MultiThreadingExamples
{
class ParametrizedThreadStartExample
{
public static void UltraCoolMethod(object o)
{
for (var i = 0; i < (int)o; i++)
{
Console.WriteLine($"Execution Thread Nº {i}");
Thread.Sleep(0);
}
}
static void Main(string[] args)
{
Thread theThread = new Thread(new ParameterizedThreadStart(UltraCoolMethod));
// You can do it Implicitly as well
// Thread theThread = new Thread(UltraCoolMethod);
theThread.Start(10);
theThread.Join();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment