-
-
Save rraallvv/92807d85eb9a4922df15 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ThreadPool | |
#include "Poco/Runnable.h" | |
#include "Poco/ThreadPool.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::ThreadPool threadpool; | |
threadpool.start(work1); | |
threadpool.start(work2); | |
threadpool.joinAll(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment