All pastes #742193 Raw Edit

Untitled

public text v1 · immutable
·published 2007-10-19 09:36 UTC
rendered paste body
class MyClass {
public:
        void start();
        void run();
};

struct Runner {
        Runner(MyClass* b) : m_b(b) {}
        void operator () () { m_b->run(); }
        MyClass* m_b;
};

void MyClass::start() {
        thread* th= new thread(Runner(this));
}

void MyClass::run() {
        cerr << "I run" << endl;
        sleep(1);
        cerr << "I runned" << endl;
}

int main ()
{
        MyClass m;
        m.start();
        sleep(60);
        cout << "exit" << endl;
}