threading - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

threading

kasirajankasirajan TamilNadu,indiaPosts: 6Member
class Program
    {
        public static void childthreadcall()
        {
            Console.WriteLine("child thread started");

        }
        static void Main(string[] args)
        {

            ThreadStart ch = new ThreadStart(childthreadcall);
            Console.WriteLine("main-creating child thread");
            Thread childthread = new Thread(ch);
            childthread.Start();
            Console.WriteLine("main-have requested the start of child thread");
            Console.ReadLine();
        }
    }

if i execute this code i got

main-creating child thread
main-have requested the start of child thread
child thread started

if i execute line-by-line by pressing f10

main-creating child thread
child thread started
main-have requested the start of child thread

can anyone explain me?

Tagged:

Comments

  • mazanujmazanuj Ukraine, KievPosts: 18Member

    Use childthread.Join(); after childthread.Start(); in main-thread to await the completion of a new thread

Sign In or Register to comment.