I want to know how I can get the parent id from a created thread. I had the idea that i make an id variable in the main function and give it as a parameter when i create the thread, but it doesn't work. Or can i get the parent id otherwise?
My code:
void first(std::thread::id id) {
//do something
cout << id << endl;
}
int main() {
std::thread::id id = std::this_thread::get_id();
std::thread thread(first, id);
return 0;
}
What are your ideas?