Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. (100 points) Create multiple threads to do tasks simultaneously. Read the C++ thread class introduction at https://en.cppreference.com/w/cpp/thread/thread then run the following code. //Example #include
1. (100 points) Create multiple threads to do tasks simultaneously. Read the C++ thread class introduction at https://en.cppreference.com/w/cpp/thread/thread then run the following code. //Example \#include \#include \#include using namespace std; // The function we want to execute on the new thread. void task1(string msg) \{ \} seut "task1 says: " msg; int main( ) \{ // Constructs the new thread and runs it. Does not block execution. thread t1(task1, "Hello"); // Do other things... // Makes the main thread wait for the new thread to finish execution, therefore blocks its own execution. t, join (; return ; \} (40 points) modify the example code and create two threads. One thread is to calculate the sum of integers from 1 to 10 and other thread is to calculate the factorial 10!. Display the results on screen. Source code and screenshot of running results are shown below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started