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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:51:18+00:00 2026-06-07T13:51:18+00:00

If I launch std::async with std::launch::async policy shouldn’t it start every async task in

  • 0

If I launch std::async with std::launch::async policy shouldn’t it start every async task in a new thread? At the moment it looks that new async tasks move to a thread which just completed it’s work. I’m using VC11 as my compiler. As you can see from the output when a new worker (e.g. a worker gets a thread with ID 34500 multiple times) is launched with std::async, it starts in a previously finished thread. Is my understanding of std::async wrong or is there an underlying work stealing queue or something of that sort?

Worker (ID=24072) starting.
Worker (ID=34500) starting.
Worker (ID=32292) starting.
Worker (ID=31392) starting.
Worker (ID=17976) starting.
Worker (ID=31580) starting.
Worker (ID=33512) starting.
Worker (ID=33804) starting.
Worker 32292 finished.
Worker (ID=32292) starting.
Worker 17976 finished.
Worker (ID=17976) starting.
Worker 31580 finished.
Worker (ID=31580) starting.
Worker 34500 finished.
Worker (ID=34500) starting.
Worker 34500 finished.
Worker (ID=34500) starting.
Worker 32292 finished.
Worker (ID=32292) starting.
Worker 17976 finished.
Worker (ID=17976) starting.
Worker 34500 finished.
Worker 17976 finished. 
Worker 31580 finished.
Worker 32292 finished.
Worker 33804 finished.
Worker 31392 finished.
Worker 33512 finished.
Worker 24072 finished.
  • 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-07T13:51:19+00:00Added an answer on June 7, 2026 at 1:51 pm

    If I launch std::async with std::launch::async policy shouldn’t it start every async task in a new thread?

    The specification requires that the asynchronous operation be executed “as if in a new thread of execution” (C++11 §30.6.8/11). The important words here are: as if.

    An already-running worker thread can be reused if and only if the behavior is the same as if a new thread was created. This means, for example, that variables with the thread_local storage class must be reset between asynchronous operations executed on a single thread.

    It is not necessary that the thread identifier be reset because a thread identifier only uniquely identifies a thread while it is running. If a thread terminates, another thread may be started with the first thread’s identifier.

    Is there an underlying work stealing queue or something of that sort?

    This is implementation-specific. The Visual C++ 2012 implementation of the C++11 thread support library is built atop the Concurrency Runtime (ConcRT), which includes a work-stealing task scheduler.

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

Sidebar

Related Questions

std::async has an overload which takes a std::launch policy as the first argument. When
I have some question about behavior of std::async function with std::launch::async policy & std::future
I'm trying to get std::async to launch a function that accepts a unique_ptr with
I'm using vc2011 and it turns out the std::async(std::launch::async, ... ) is a bit
Does anyone has experience with the rather new std::async ? We are currently implementing
#include <iostream> #include <thread> using namespace std; thread&& launch(){ thread launchee([](){ this_thread::sleep_for(chrono::milliseconds(280)); cout<<HA!<<endl; });
I launch an executable in the usual way: Process p = new Process(); p.StartInfo.UseShellExecute
I launch an activity to capture a picture from camera: Intent i = new
I launch a method that is, essentially, an endless loop using dispatch_queue_create and then
Application launch through Java web start(JWS) checks for update when we are launching it.

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.