Skip to content

Instantly share code, notes, and snippets.

@rraallvv
Forked from sumnjc/thread2.cpp
Created August 9, 2014 23:24
Show Gist options
  • Save rraallvv/92807d85eb9a4922df15 to your computer and use it in GitHub Desktop.
Save rraallvv/92807d85eb9a4922df15 to your computer and use it in GitHub Desktop.
// 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