- Model: Robert J. Lang’s Butterfly
- Folded by: Rafał Cieślak
- Paper size: 36cm (14″) square sheet
- Model size: 15cm (6″) wing span
- Paper type: Waxed-tissue-foil¹
- Folding time: ~5h
Recently I have noticed an unobvious problem that may appear when using std::threads as class fields. I believe it is more than likely to meet if one is not careful enough when implementing C++ classes, due to it’s tricky nature. Also, its solution provides an elegant example of what has to be considered when working with threads in object-oriented C++, therefore I decided to share it.
Consider a scenario where we would like to implement a class that represents a particular thread activity. We would like it to:
I will present the obvious implementation, explain the problem with it, and describe how to deal with it.