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 6749429
In Process

The Archive Base Latest Questions

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

See the following code: boost::thread_group threads; boost::barrier barrier(10); thing pThing; for( size_t i =

  • 0

See the following code:

boost::thread_group threads;
boost::barrier      barrier(10);
thing               pThing;

for( size_t i = 0; i < 10; ++i )
{
    threads.create_thread(
        [&barrier, &pThing]()
        {
            while( true )
            {
                // do some stuff with pThing
                if( barrier.wait() )    //  let all threads catch up before resettings, and only 1 thread resets
                    pThing.Reset();
                barrier.wait();         //  let all threads wait until the reset is completed
            }
        });
}

threads.join_all();

Questions:

  1. Do I need a way to break the while(true) for the threads to exit correctly?
  2. Will join_all() complete since all the threads are infinite looping?
  3. what happens when a thread finishes its work, does it die?
  4. Is barrier.wait() an interruption point?
  5. Do interruption points just yield the thread?
  6. What happens when the thread_group dies; Do I even need to join_all() if the thread group it going to die right afterwards anyway?
  • 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-26T12:41:22+00:00Added an answer on May 26, 2026 at 12:41 pm
    1. No, you can also terminate a thread with exception. Interruption exception is a clean way to do it.
    2. Issue interrupt_all() call first.
    3. Yes, it cannot be resumed.
    4. Yes.
    5. I don’t understand your question. Interruption point is a point at which ‘am-I-interrupted?’ flag is checked and if it’s true, exception is thrown. interrupt() call sets this flag on a thread and, additionally, makes the thread stop waiting if that’s what it’s doing currently.
    6. As far as I understand, threads continue to exist, i.e. they are not somehow forced to die. You need to make sure threads do exit (which inherently depends on what code your threads execute), then join_all() and only then destroy the thread group object.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, and although the call to boost::filesystem::create_directory returns true ,
How can I implement cross browser opacity gradient (not color gradient)? See following code:
The following code does not want to compile. See the included error message. Code:
(resolved: see bottom) I have the following code snippet: Protected Sub SqlDataSource1_Inserted(ByVal sender As
i have written the following code: As you can see there is a for
When I compile the following code, I only see the error during Run-time which
I m having the following code, however, I can see that the radio button
I have the following recursive code and it doesn't behave as expected (see details
If we look at the latest jQuery source at http://code.jquery.com/jquery-latest.js we see the following:
I see a lot of code similar to the following var customrs = MyDataContext.Customers.Where(...);

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.