Skip to content

Instantly share code, notes, and snippets.

@sumnjc
Created December 10, 2012 03:25

Revisions

  1. sumnjc created this gist Dec 10, 2012.
    34 changes: 34 additions & 0 deletions thread1.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    // sample of using POCO's Thread

    #include "Poco/Runnable.h"
    #include "Poco/Thread.h"
    #include <iostream>

    using namespace std;

    class Worker:public Poco::Runnable{
    public:
    Worker(int n):_id(n){}
    virtual void run() {
    cout << "i'm worker:" << _id << endl;
    }
    private:
    int _id;
    };

    int main(int argc, char **argv)
    {
    Worker work1(1);
    Worker work2(2);

    Poco::Thread thread1;
    Poco::Thread thread2;

    thread1.start(work1);
    thread2.start(work2);

    thread1.join();
    thread2.join();

    return 0;
    }