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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:47:22+00:00 2026-06-14T12:47:22+00:00

Possible Duplicate: Simple example of threading in C++ Can someone please give me an

  • 0

Possible Duplicate:
Simple example of threading in C++

Can someone please give me an example how to create a simple application in C++ that runs two functions simultaneously? I know that this question have connections with thread management and multi-threading, but I’m basically a php programmer and I’m not really familiar with advanced C++ programming.

  • 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-14T12:47:23+00:00Added an answer on June 14, 2026 at 12:47 pm

    Here’s a simple example:

    #include <iostream>
    #include <thread>
    
    void f1() { std::cout << "This is function 1.\n"; }
    void f2() { std::cout << "This is a different function, let's say 2.\n"; }
    
    int main()
    {
        std::thread t1(f1), t2(f2);   // run both functions at once
    
        // Final synchronisation:
        // All running threads must be either joined or detached
        t1.join();
        t2.join();
    }
    

    If your functions need to produce return values, you should combine the above thread objects with std::packaged_task runnable objects, available from <future>, which give you access to the return value of the thread function.

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

Sidebar

Related Questions

Possible Duplicate: Javascript closure inside loops - simple practical example Please explain the use
Possible Duplicate: Very simple C# CSV reader In my application the user can export
Possible Duplicate: Javascript closure inside loops - simple practical example How can I make
Possible Duplicate: Timezone conversion in php Here is a simple example of what i
Possible Duplicate: Dirt-simple PHP templates… can this work without eval ? Let's say I
Possible Duplicate: Stopping & Starting music on incoming calls I have a simple application
Possible Duplicate: What is a simple example of floating point/rounding error? When I execute
Possible Duplicate: Why does my simple C++ GUI application show a message box in
Possible Duplicate: extending from two classes I'm currently trying to make a simple Mod
Possible Duplicate: C++ Singleton design pattern. How can I create only one instance of

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.