-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
5 lines (3 loc) · 682 Bytes
/
README
File metadata and controls
5 lines (3 loc) · 682 Bytes
1
2
3
4
5
Basic threading example shows the addition race between a for-loop in main() vs. an SDL-based thread while-loop.
There is a parent, general thread class CThread that has as much generality as possible so that wildly different types of subclass threads can be designed. The subclass thread included here is CThread_Add, where an input integer is increased by increments of 1 until the thread is stopped.
The results are highly dependent on the ratio of the sleep durations in the for- and while- loop. Because the thread is slightly slower than the main() for-loop, it may be stopped before it can reach the maximum number of loops possible, given the for-loop's usleep() command.