Join a Thread

Once started, a thread's IsAlive property returns true, until the point where the thread ends.

A thread ends when the delegate passed to the Thread's constructor finishes executing.

Once ended, a thread cannot restart.

You can wait for another thread to end by calling its Join method.

Here's an example:

 
using System;
using System.Threading;

class ThreadTest
{
    static void Main()
    {
        Thread t = new Thread(Go);
        t.Start();
        t.Join();
        Console.WriteLine("Thread t has ended!");
    }

    static void Go() { 
        for (int i = 0; i < 10; i++) 
            Console.Write("y"); 
    }
}

The output:


yyyyyyyyyyThread t has ended!
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.