-
-
Save jitpaul/a08b021425bf3e3074f38456aae6282a to your computer and use it in GitHub Desktop.
Multithreading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <thread> | |
#include <future> | |
using namespace std; | |
void func(promise<int>&& a) { | |
a.set_value(4); | |
} | |
int main() { | |
promise<int> pr; | |
auto fut = pr.get_future(); | |
thread t(&func,move(pr)); | |
t.detach(); | |
cout << fut.get(); | |
cin.get(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment