<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FThread%2FThread_Creation</id>
		<title>Csharp/CSharp Tutorial/Thread/Thread Creation - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FThread%2FThread_Creation"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Thread_Creation&amp;action=history"/>
		<updated>2026-04-29T21:32:18Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Thread_Creation&amp;diff=6654&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Thread_Creation&amp;diff=6654&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Thread_Creation&amp;diff=6655&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Thread/Thread_Creation&amp;diff=6655&amp;oldid=prev"/>
				<updated>2010-05-26T12:20:10Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Adding with Thread objects==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class AddParams {&lt;br /&gt;
    public int a;&lt;br /&gt;
    public int b;&lt;br /&gt;
    public AddParams(int numb1, int numb2) {&lt;br /&gt;
        a = numb1;&lt;br /&gt;
        b = numb2;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Program {&lt;br /&gt;
    public static void Add(object data) {&lt;br /&gt;
        if (data is AddParams) {&lt;br /&gt;
            Console.WriteLine(&amp;quot;ID of thread in Add(): {0}&amp;quot;,Thread.CurrentThread.GetHashCode());&lt;br /&gt;
            AddParams ap = (AddParams)data;&lt;br /&gt;
            Console.WriteLine(&amp;quot;{0} + {1} is {2}&amp;quot;, ap.a, ap.b, ap.a + ap.b);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;ID of thread in Main(): {0}&amp;quot;, Thread.CurrentThread.GetHashCode());&lt;br /&gt;
        AddParams ap = new AddParams(10, 10);&lt;br /&gt;
        Thread t = new Thread(new ParameterizedThreadStart(Add));&lt;br /&gt;
        t.Start(ap);&lt;br /&gt;
        Console.ReadLine();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Communicating Data to a Thread==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
   &lt;br /&gt;
class Sum {&lt;br /&gt;
    public Sum(int op1, int op2) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;[Sum.Sum] Instantiated with values of {0} and {1}&amp;quot;, op1, op2);&lt;br /&gt;
        this.op1 = op1;&lt;br /&gt;
        this.op2 = op2;&lt;br /&gt;
    }&lt;br /&gt;
    int op1;&lt;br /&gt;
    int op2;&lt;br /&gt;
    int result;&lt;br /&gt;
    public int Result{ get { return result; } }&lt;br /&gt;
   &lt;br /&gt;
    public void Add()&lt;br /&gt;
    {&lt;br /&gt;
        Thread.Sleep(5000);&lt;br /&gt;
        result = op1 + op2;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
class ThreadData {&lt;br /&gt;
    static void Main() {&lt;br /&gt;
        Sum sum = new Sum(6, 42);&lt;br /&gt;
   &lt;br /&gt;
        Thread thread = new Thread(new ThreadStart(sum.Add));&lt;br /&gt;
        thread.Start();&lt;br /&gt;
   &lt;br /&gt;
        for (int i = 0; i &amp;lt; 10; i++) {&lt;br /&gt;
            Thread.Sleep(200);&lt;br /&gt;
            Console.Write(&amp;quot;.&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        thread.Join();&lt;br /&gt;
   &lt;br /&gt;
        Console.WriteLine(&amp;quot;[Main] The result is {0}&amp;quot;, sum.Result);&lt;br /&gt;
        Console.ReadLine();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create a thread of execution==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Threading; &lt;br /&gt;
 &lt;br /&gt;
class MyThread { &lt;br /&gt;
  public int count; &lt;br /&gt;
  string thrdName; &lt;br /&gt;
 &lt;br /&gt;
  public MyThread(string name) { &lt;br /&gt;
    count = 0; &lt;br /&gt;
    thrdName = name; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // Entry point of thread. &lt;br /&gt;
  public void run() { &lt;br /&gt;
    Console.WriteLine(thrdName + &amp;quot; starting.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      Thread.Sleep(500); &lt;br /&gt;
      Console.WriteLine(&amp;quot;In &amp;quot; + thrdName + &lt;br /&gt;
                        &amp;quot;, count is &amp;quot; + count); &lt;br /&gt;
      count++; &lt;br /&gt;
    } while(count &amp;lt; 10); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(thrdName + &amp;quot; terminating.&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    Console.WriteLine(&amp;quot;Main thread starting.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    MyThread mt = new MyThread(&amp;quot;Child #1&amp;quot;); &lt;br /&gt;
    Thread newThrd = new Thread(new ThreadStart(mt.run)); &lt;br /&gt;
 &lt;br /&gt;
    newThrd.Start(); &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      Console.Write(&amp;quot;.&amp;quot;); &lt;br /&gt;
      Thread.Sleep(100); &lt;br /&gt;
    } while (mt.count != 10); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Main thread ending.&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Main thread starting.&lt;br /&gt;
Child #1 starting.&lt;br /&gt;
.....In Child #1, count is 0&lt;br /&gt;
.....In Child #1, count is 1&lt;br /&gt;
....In Child #1, count is 2&lt;br /&gt;
.....In Child #1, count is 3&lt;br /&gt;
....In Child #1, count is 4&lt;br /&gt;
.....In Child #1, count is 5&lt;br /&gt;
.....In Child #1, count is 6&lt;br /&gt;
....In Child #1, count is 7&lt;br /&gt;
.....In Child #1, count is 8&lt;br /&gt;
....In Child #1, count is 9&lt;br /&gt;
Child #1 terminating.&lt;br /&gt;
Main thread ending.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create multiple threads of execution==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Threading; &lt;br /&gt;
 &lt;br /&gt;
class MyThread { &lt;br /&gt;
  public int count; &lt;br /&gt;
  public Thread thrd; &lt;br /&gt;
 &lt;br /&gt;
  public MyThread(string name) { &lt;br /&gt;
    count = 0; &lt;br /&gt;
    thrd = new Thread(this.run); &lt;br /&gt;
    thrd.Name = name; &lt;br /&gt;
    thrd.Start(); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  void run() { &lt;br /&gt;
    Console.WriteLine(thrd.Name + &amp;quot; starting.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    do { &lt;br /&gt;
      Thread.Sleep(500); &lt;br /&gt;
      Console.WriteLine(&amp;quot;In &amp;quot; + thrd.Name + &lt;br /&gt;
                        &amp;quot;, count is &amp;quot; + count); &lt;br /&gt;
      count++; &lt;br /&gt;
    } while(count &amp;lt; 10); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(thrd.Name + &amp;quot; terminating.&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    Console.WriteLine(&amp;quot;Main thread starting.&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    MyThread mt1 = new MyThread(&amp;quot;Child #1&amp;quot;); &lt;br /&gt;
    MyThread mt2 = new MyThread(&amp;quot;Child #2&amp;quot;); &lt;br /&gt;
    MyThread mt3 = new MyThread(&amp;quot;Child #3&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Thread.Sleep(10000); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Main thread ending.&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Main thread starting.&lt;br /&gt;
Child #1 starting.&lt;br /&gt;
Child #2 starting.&lt;br /&gt;
Child #3 starting.&lt;br /&gt;
In Child #1, count is 0&lt;br /&gt;
In Child #2, count is 0&lt;br /&gt;
In Child #3, count is 0&lt;br /&gt;
In Child #1, count is 1&lt;br /&gt;
In Child #2, count is 1&lt;br /&gt;
In Child #3, count is 1&lt;br /&gt;
In Child #1, count is 2&lt;br /&gt;
In Child #2, count is 2&lt;br /&gt;
In Child #3, count is 2&lt;br /&gt;
In Child #1, count is 3&lt;br /&gt;
In Child #2, count is 3&lt;br /&gt;
In Child #3, count is 3&lt;br /&gt;
In Child #1, count is 4&lt;br /&gt;
In Child #2, count is 4&lt;br /&gt;
In Child #3, count is 4&lt;br /&gt;
In Child #1, count is 5&lt;br /&gt;
In Child #2, count is 5&lt;br /&gt;
In Child #3, count is 5&lt;br /&gt;
In Child #2, count is 6&lt;br /&gt;
In Child #1, count is 6&lt;br /&gt;
In Child #3, count is 6&lt;br /&gt;
In Child #2, count is 7&lt;br /&gt;
In Child #1, count is 7&lt;br /&gt;
In Child #3, count is 7&lt;br /&gt;
In Child #2, count is 8&lt;br /&gt;
In Child #1, count is 8&lt;br /&gt;
In Child #3, count is 8&lt;br /&gt;
In Child #2, count is 9&lt;br /&gt;
Child #2 terminating.&lt;br /&gt;
In Child #1, count is 9&lt;br /&gt;
Child #1 terminating.&lt;br /&gt;
In Child #3, count is 9&lt;br /&gt;
Child #3 terminating.&lt;br /&gt;
^CTerminate batch job (Y/N)? n&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==List threads for PID==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
  class Program&lt;br /&gt;
  {&lt;br /&gt;
    static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
      Process theProc = null;&lt;br /&gt;
      try&lt;br /&gt;
      {&lt;br /&gt;
        theProc = Process.GetProcessById(12344);&lt;br /&gt;
      }&lt;br /&gt;
      catch&lt;br /&gt;
      {&lt;br /&gt;
        Console.WriteLine(&amp;quot;-&amp;gt; Sorry...bad PID!&amp;quot;);&lt;br /&gt;
        return;&lt;br /&gt;
      }&lt;br /&gt;
      Console.WriteLine(&amp;quot;Here are the threads used by: {0}&amp;quot;,theProc.ProcessName);&lt;br /&gt;
      ProcessThreadCollection theThreads = theProc.Threads;&lt;br /&gt;
      foreach (ProcessThread pt in theThreads)&lt;br /&gt;
      {&lt;br /&gt;
        string info = string.Format(&amp;quot;-&amp;gt; Thread ID: {0}\tStart Time {1}\tPriority {2}&amp;quot;,pt.Id, pt.StartTime.ToShortTimeString(), pt.PriorityLevel);&lt;br /&gt;
        Console.WriteLine(info);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing an argument to the thread method.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;  &lt;br /&gt;
using System.Threading;  &lt;br /&gt;
  &lt;br /&gt;
class MyThread {  &lt;br /&gt;
  public int count;  &lt;br /&gt;
  public Thread thrd;  &lt;br /&gt;
 &lt;br /&gt;
  public MyThread(string name, int num) {  &lt;br /&gt;
    count = 0;  &lt;br /&gt;
 &lt;br /&gt;
    thrd = new Thread(new ParameterizedThreadStart(this.run)); &lt;br /&gt;
 &lt;br /&gt;
    thrd.Name = name; &lt;br /&gt;
 &lt;br /&gt;
    thrd.Start(num);  &lt;br /&gt;
  }  &lt;br /&gt;
  &lt;br /&gt;
  void run(object num) {  &lt;br /&gt;
    Console.WriteLine(thrd.Name + &amp;quot; starting with count of &amp;quot; + num);  &lt;br /&gt;
  &lt;br /&gt;
    do {  &lt;br /&gt;
      Thread.Sleep(500);  &lt;br /&gt;
      Console.WriteLine(&amp;quot;In &amp;quot; + thrd.Name + &amp;quot;, count is &amp;quot; + count);  &lt;br /&gt;
      count++;  &lt;br /&gt;
    } while(count &amp;lt; (int) num);  &lt;br /&gt;
  &lt;br /&gt;
    Console.WriteLine(thrd.Name + &amp;quot; terminating.&amp;quot;);  &lt;br /&gt;
  }  &lt;br /&gt;
}  &lt;br /&gt;
  &lt;br /&gt;
class MainClass {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    MyThread mt = new MyThread(&amp;quot;Child #1&amp;quot;, 5);  &lt;br /&gt;
    MyThread mt2 = new MyThread(&amp;quot;Child #1&amp;quot;, 3);  &lt;br /&gt;
  &lt;br /&gt;
    do {  &lt;br /&gt;
      Thread.Sleep(100);  &lt;br /&gt;
    } while (mt.thrd.IsAlive | mt2.thrd.IsAlive);  &lt;br /&gt;
  &lt;br /&gt;
    Console.WriteLine(&amp;quot;Main thread ending.&amp;quot;);  &lt;br /&gt;
  }  &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Child #1 starting with count of 5&lt;br /&gt;
Child #1 starting with count of 3&lt;br /&gt;
In Child #1, count is 0&lt;br /&gt;
In Child #1, count is 0&lt;br /&gt;
In Child #1, count is 1&lt;br /&gt;
In Child #1, count is 1&lt;br /&gt;
In Child #1, count is 2&lt;br /&gt;
In Child #1, count is 2&lt;br /&gt;
Child #1 terminating.&lt;br /&gt;
In Child #1, count is 3&lt;br /&gt;
In Child #1, count is 4&lt;br /&gt;
Child #1 terminating.&lt;br /&gt;
Main thread ending.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Primary Thread statistcs==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class Program {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        Thread primaryThread = Thread.CurrentThread;&lt;br /&gt;
        primaryThread.Name = &amp;quot;ThePrimaryThread&amp;quot;;&lt;br /&gt;
        Console.WriteLine(&amp;quot;Name of current AppDomain: {0}&amp;quot;, Thread.GetDomain().FriendlyName);&lt;br /&gt;
        Console.WriteLine(&amp;quot;ID of current Context: {0}&amp;quot;, Thread.CurrentContext.ContextID);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Thread Name: {0}&amp;quot;, primaryThread.Name);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Has thread started?: {0}&amp;quot;, primaryThread.IsAlive);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Priority Level: {0}&amp;quot;, primaryThread.Priority);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Thread State: {0}&amp;quot;, primaryThread.ThreadState);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Starting a Method in a Separate Thread==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public const int Repetitions = 1000;&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
      ThreadStart threadStart = new ThreadStart(DoWork);&lt;br /&gt;
      Thread thread = new Thread(threadStart);&lt;br /&gt;
      thread.Start();&lt;br /&gt;
      for (int count = 0; count &amp;lt; Repetitions; count++)&lt;br /&gt;
      {&lt;br /&gt;
          Console.Write(&amp;quot;-&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      thread.Join();&lt;br /&gt;
  }&lt;br /&gt;
  public static void DoWork()&lt;br /&gt;
  {&lt;br /&gt;
      for (int count = 0; count &amp;lt; Repetitions; count++)&lt;br /&gt;
      {&lt;br /&gt;
          Console.Write(&amp;quot;.&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==The creation of threads==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
class MainClass {&lt;br /&gt;
   public static void Countdown() {&lt;br /&gt;
    for (int i = 10; i &amp;gt; 0; i--) {&lt;br /&gt;
      Console.Write(i.ToString() + &amp;quot; &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static void Main() {&lt;br /&gt;
    Thread t2 = new Thread(new ThreadStart(Countdown));&lt;br /&gt;
    t2.Start();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;10 9 8 7 6 5 4 3 2 1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Thread method with no parameter==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime;&lt;br /&gt;
using System.Runtime.rupilerServices;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Thread thread = new Thread(WorkerOperation);&lt;br /&gt;
        thread.Start();&lt;br /&gt;
        thread.Join();&lt;br /&gt;
    }&lt;br /&gt;
    private static void WorkerOperation()&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Simple worker&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Simple worker&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Thread method with parameter==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime;&lt;br /&gt;
using System.Runtime.rupilerServices;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Thread paramThread = new Thread(ParameterizedWorkerOperation);&lt;br /&gt;
        paramThread.Start(&amp;quot;Test&amp;quot;);&lt;br /&gt;
        paramThread.Join();&lt;br /&gt;
    }&lt;br /&gt;
    private static void ParameterizedWorkerOperation(object o)&lt;br /&gt;
    {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Param worker: {0}&amp;quot;, o);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Param worker: Test&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Thread Stats==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
  class Program&lt;br /&gt;
  {&lt;br /&gt;
    static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
      Thread primaryThread = Thread.CurrentThread;&lt;br /&gt;
      primaryThread.Name = &amp;quot;ThePrimaryThread&amp;quot;;&lt;br /&gt;
      Console.WriteLine(&amp;quot;Name of current AppDomain: {0}&amp;quot;,Thread.GetDomain().FriendlyName);&lt;br /&gt;
      Console.WriteLine(&amp;quot;ID of current Context: {0}&amp;quot;,Thread.CurrentContext.ContextID);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Thread Name: {0}&amp;quot;,primaryThread.Name);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Has thread started?: {0}&amp;quot;,primaryThread.IsAlive);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Priority Level: {0}&amp;quot;,primaryThread.Priority);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Thread State: {0}&amp;quot;,primaryThread.ThreadState);&lt;br /&gt;
    }&lt;br /&gt;
  }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use anonymous delegate as the worker method to create Thread==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
using System.Runtime;&lt;br /&gt;
using System.Runtime.rupilerServices;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        int threadCount = 5;&lt;br /&gt;
        Thread[] threads = new Thread[threadCount];&lt;br /&gt;
        for (int i = 0; i &amp;lt; threadCount; i++)&lt;br /&gt;
        {&lt;br /&gt;
            int idx = i;&lt;br /&gt;
            threads[i] = new Thread(delegate() { Console.WriteLine(&amp;quot;Worker {0}&amp;quot;, idx); });&lt;br /&gt;
        }&lt;br /&gt;
        Array.ForEach(threads, delegate(Thread t) { t.Start(); });&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Worker 0&lt;br /&gt;
Worker 1&lt;br /&gt;
Worker 2&lt;br /&gt;
Worker 3&lt;br /&gt;
Worker 4&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>