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
/* Learning :
When we detach the thread object, it generates default thread ID.
So, code will complete execution as assert statement is ok.
*/
#include <iostream>
#include <thread>
#include <cassert>
using namespace std;
void Test()
{
cout << endl << "Hi from Thread function " << endl;
}
int main()
{
thread t1(Test);
t1.detach();
thread::id i1 = t1.get_id();
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run