Skip to content

Instantly share code, notes, and snippets.

@jitpaul

jitpaul/thread1 Secret

Created May 8, 2018 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jitpaul/a08b021425bf3e3074f38456aae6282a to your computer and use it in GitHub Desktop.
Save jitpaul/a08b021425bf3e3074f38456aae6282a to your computer and use it in GitHub Desktop.
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