CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <mutex>
#include <condition_variable>
#include <sstream>
using namespace std;
class myThreadPool
{
public:
myThreadPool(int cnt) : m_intTotalThreads(cnt) , m_bIsToTerminate(false) { m_vThreads.resize(m_intTotalThreads); }
void start()
{
for (int i = 0; i < m_intTotalThreads; i++)
{
m_vThreads.at(i) = thread(&myThreadPool::ThreadLoop,this);
}
}
void ThreadLoop()
{
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run