-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCThread_Add.cpp
More file actions
30 lines (22 loc) · 850 Bytes
/
CThread_Add.cpp
File metadata and controls
30 lines (22 loc) · 850 Bytes
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
29
30
#include "CThread_Add.h"
#include <iostream>
using namespace std;
CThread_Add::CThread_Add() {
// don't need to iterate threadCount because the parent class takes care of that
}
CThread_Add::~CThread_Add() {
}
int CThread_Add::execute() {
cout << "\nCThread_Add.execute() is running now.\n" << endl;
workingInt = *(static_cast<int*>(workingData)); // convert workingData to workingInt
int threadIterations = 0;
do {
threadIterations++;
//cout << " *** thread has iterated " << threadIterations << " times." << endl;
workingInt += 1;
workingData = static_cast<void*>(&workingInt); // convert workingInt to workingData
//remember that update() uses workingData, so it must be immediately updated by recasting workingInt. Otherwise the update() function will not work.
usleep(5000);
} while (stopped == false);
return 1;
}