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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:40:58+00:00 2026-06-17T15:40:58+00:00

When using loops (particularly in c++) do they all create their own threads? If

  • 0

When using loops (particularly in c++) do they all create their own threads? If not which loops create their own threads as opposed to which ones take control of execution of the main thread for the duration of their existence?

EDIT: What about the message loop which runs continuously, how come it’s existence in a program doesn’t prevent anything after the message loop from being executed since it’s a continuous loop?

  • 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-17T15:40:59+00:00Added an answer on June 17, 2026 at 3:40 pm

    Loops, such as for-loops and while-loops never create threads. The main thread (or any other thread started somewhere in your code) can enter a loop, just like it can perform all other parts of your code, but a new thread will never be started as a result of entering a loop.

    There are special libraries that provide templates that can be used in a way similar to loops, e.g. parallel_for. Those will be starting threads (or similar kinds of parallelism), but those are really function templates (or class templates), not loop statements as defined by the language standard.

    EDIT after comment:
    In the specific example of a message loop you refer to in the comment below, the idea is that windows (which react to events coming from separate threads) and possibly various other threads are created before the main thread enters the loop. The loop then runs until a WM_QUIT message is received, causing GetMessage to return the equivalent of boolean false.

    So the loop runs in the main thread, but the messages it receives are generated by separate threads, created and started (either by the system or by you) before entering the loop.

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

Sidebar

Related Questions

I could do this using loops, but is there a way to take two
I am using very similar loops to iterate all public fields and properties of
I've created a simple Outlook 2007 add-in using C# which loops through a selection
I could solve this using loops, but I am trying think in vectors so
Can anyone let me know how to parallelize for loops using Java 5's JParallelLoops.jar
I often end up writing a bit of code twice when using a loops.
In runtime I'm creating a DataTable and using nested for-loops to populate the table.
During many, sometimes inundating, debugging sessions using DDD, I stumble upon loops. And I
So I create multiple BackgroundWorkers using loop: foreach (var item in list) { worker
I have a macro that I'm using to remove all of the color in

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.