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

  • Home
  • SEARCH
  • 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 6755087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:21:30+00:00 2026-05-26T13:21:30+00:00

when parent thread sleep does sub threads also sleep ? Now main thread is

  • 0

when parent thread sleep does sub threads also sleep ?

Now main thread is UI
I create 20 sub threads inside main thread with task factory (lets call threads 2)
Inside of this 20 sub threads i create another 10 sub threads again with sub factory (lets call threads 3)

Now inside of this threads 2 i have infinite loop. Inside of infinite loop checking whether threads 3 completed or not. If completed dispose completed thread and start another thread. I am using 250 ms sleep for each checking inside infinite while loop. So when threads 2 in sleep does also threads 3 sleep or they are independent. Here the code you can see.

while (true)
{
    int irActiveThreadCount = 0;
    int irFinishedLast = -1;

    for (int i = 0; i < irPerMainSiteThreadCount; i++)
    {
        if (MainSitesTaskList[irWhichMainTask, i] == null)
        {
            irFinishedLast = i;
            break;
        }
        if (MainSitesTaskList[irWhichMainTask, i].IsCompleted == true)
        {
            irFinishedLast = i;
            break;
        }
    }

    for (int i = 0; i < irPerMainSiteThreadCount; i++)
    {
        if (MainSitesTaskList[irWhichMainTask, i] != null)
            if (MainSitesTaskList[irWhichMainTask, i].IsCompleted == false)
            {
                irActiveThreadCount++;
            }
    }

    if (irFinishedLast > -1)
    {
        var newTask = Task.Factory.StartNew(() =>
        {
            fcStartSubPageCrawl(srMainSiteURL, srMainSiteId, irWhichMainTask);
        });
        lock (lockerMainSitesArray)
        {
            if (MainSitesTaskList[irWhichMainTask, irFinishedLast] != null)
                MainSitesTaskList[irWhichMainTask, irFinishedLast].Dispose();
            MainSitesTaskList[irWhichMainTask, irFinishedLast] = newTask;
        }
    }

    Thread.Sleep(250);

    srQuery = "myquery";
    using (DataSet dsTemp = DbConnection.db_Select_Query(srQuery))
    {
        if (dsTemp != null)
            if (dsTemp.Tables.Count > 0)
                if (dsTemp.Tables[0].Rows.Count == 0)
                {
                    break;
                }
    }
}
  • 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-05-26T13:21:31+00:00Added an answer on May 26, 2026 at 1:21 pm

    There’s no such thing as a “parent” thread really. One thread starts another, but then there’s no particular relationship between them. For example, the starting thread can terminate without any of the new threads dying.

    The starting thread sleeping definitely doesn’t affect any other thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Child threads sleeps to wait condition, and the parent thread can call some routine
I have a parent thread (non-UI) which creates some child threads to do some
I have a parent thread (non-UI) which creates some child threads to do some
I read that threads share the memory address space of it's parent thread. If
I have a PARENT thread responsible for performing jobs, for each job it launches
A parent has several child threads. If user click on stop button the parent
Here's my situation. Let's say I would like to create a thread that continually
Is there a way to have the parent that spawned a new thread catch
Possible Duplicate: .NET Is there a way to get the parent thread id? Is
As we know, C#'s built-in thread model does not support the passing of return

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.