Skip to content

Instantly share code, notes, and snippets.

@jitpaul

jitpaul/thread1 Secret

Created May 8, 2018
Embed
What would you like to do?
Multithreading
#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