#include <iostream>
#include <future>
#include <chrono>
using namespace std;
mutex outMutex;
class Test
{
public:
    Test(){}
    void out(int No, double& q) const
    {
        {
            lock_guard<mutex> tst(outMutex);
            cout << "<- " << No << " -- " << &q << endl;
        }
        this_thread::sleep_for(chrono::seconds(1));
    }
    void test() const;
};
void Test::test() const
{
    double w[2];
    cout << "-> " << 0 << " -- " << &w[0] << endl;
    future<void> f1 = async( &Test::out,this,0,ref(w[0]));
    {
        lock_guard<mutex> tst(outMutex);
        cout << "-> " << 1 << " -- " << &w[1] << endl;
    }
    future<void> f2 = async( &Test::out,this,1,ref(w[1]));
    f1.get();
    f2.get();
}
int main(int argc, const char * argv[])
{
    try {
        Test t;
        t.test();
    }
    catch(exception&e)
    {
        cout << "\n" << e.what() << endl;
    }
}