-
-
Save digitalist/dc2347a16ad417d05d602f2355fe870f to your computer and use it in GitHub Desktop.
POCO Simple Thread example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CMakeLists.txt