CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <sstream>
#include <thread>
#include <fstream>
using namespace std;
void testFun1()
{
auto tId = this_thread::get_id;
stringstream ss;
ss << tId;
string strThreadId = ss.str();
string strStarted = "Started test fun by thread id " + strThreadId + "\n";
cout << strStarted;
this_thread::sleep_for(chrono::seconds(5));
string strEnded = "Thread id " + strThreadId + " is completed\n";
cout << strEnded;
}
class testClass
{
public:
void operator()()
{
fstream fObj("test.txt",std::ios::app);
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run