Untitled
unknown
plain_text
9 months ago
650 B
7
Indexable
#include <iostream>
#include <bits/stdc++.h>
#include <thread>
using namespace std;
void function1 (char symbol)
{
for (int i = 0; i < 20000000; i++)
cout<<symbol;
}
void function2()
{
for (int i = 0; i < 20000000; i++)
cout<<"-";
}
int main()
{
time_t start, end;
time(&start);
ios_base::sync_with_stdio(false);
thread worker1(function1, 'A');
thread worker2(function2);
function2();
time(&end);
double time_taken = double(end start);
cout << "Time taken by program is : <<< fixed
<<< time_taken << setprecision(20);
cout << " sec << endl;
return 0;
}
}
}
}Editor is loading...
Leave a Comment