Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8744143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:47:57+00:00 2026-06-13T11:47:57+00:00

I have created threads dynamically. static void Main(string[] args) { int ThreadCount =Convert.ToInt32ConfigurationManager.AppSettings[Threads]); List<Thread>

  • 0

I have created threads dynamically.

static void Main(string[] args)
{

    int ThreadCount =Convert.ToInt32ConfigurationManager.AppSettings["Threads"]);
    List<Thread> th = new List<Thread>();
    for (int i = 0; i < ThreadCount; i++)
    {
      Thread t = new Thread(print);
      th.Add(t);
    }
    foreach (Thread t in th)
    {
       t.Start();
    }
 }
 public static void print()
 {
    console.writeline("123");
 }

I want to know when this threads will complete.
On completion of these threads I want to print a message of “DONE”

How can I do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:47:58+00:00Added an answer on June 13, 2026 at 11:47 am

    Thread.Join() could help; see http://msdn.microsoft.com/en-us/library/95hbf2ta.aspx.

    foreach (var t in th)
       t.Join();
    
    Console.WriteLine("DONE");
    

    You might want to look at the higher level TPL (Task Parallel Library) API; see http://msdn.microsoft.com/en-us/library/dd537609.aspx. It could be easier to use in the long run.

    var tasks[] = new Task[n];
    for (int i = 0; i < n; ++i)
    {
       tasks[i] = new Task(() => Console.WriteLine(123));
       tasks[i].Start();
    }
    
    Tasks.WaitAll(tasks);
    Console.WriteLine("DONE");
    

    Or in PLINQ , http://msdn.microsoft.com/en-us/library/dd460688.aspx, (haven’t compiled the code)

    Parallel.ForEach(Enumerable.Range(1, n), i => Console.WriteLine(i));
    Console.WriteLine("DONE");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some BitmapFrames created on a thread other than the main UI thread;
I have a business application (created from template) and I can change language dynamically
Background: In my application written in C++, I have created 3 threads: AnalysisThread (or
HI Guys, I have created a windows service which spawns three threads.The first thread
I have created two threads and i want to see their priority after they
I have created two threads . By default they have a priority of 0
I have created class by implementing runnable interface and then created many threads(nearly 10)
I am new to Objective C programming. I have created two threads called add
My program have several worker threads that calling a function in a dynamically loaded
I have a form that is dynamically created. It is a winForms application. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.