In: Computer Science
C++
Create a C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0.
#include#include using namespace std; void countUp() { int i; for(i = 0; i <= 20; i++) { cout << i << endl; } cout << endl << endl; } void countDown() { int i; for(i = 20; i >= 0; i--) { cout << i << endl; } } int main() { thread countUpThread(countUp); countUpThread.join(); thread countDownThread(countDown); countDownThread.join(); return 0; }