threadExample
threadExample

Learning Objectives
This example demonstrates how to use threads and what impact it has to lock a threaded function. It includes an example function that creates a noisy texture. This function is executed in a parallel thread, that means you can do other stuff in the mainupdate() loop that will not be affected by the computation time of the noise texture. Not locking the function that creates the texture will lead to tearing since the buffer of the pixels is accessible even if the current processing step of all pixels is not complete.
Pay attention to ..
- how to write your own class derived from ofThread
- the use and affect of std::condition_variable
Expected Behavior
When launching this app, you should see a screen with some organic blob noise animation and instructions on the top left of the screen.
Instructions for use:
- Press
sto stop the thread and therefore the animation andato run it again. - Press
lto lock the threaded function andnto remove the lock.
Other classes used in this file
This Example uses the following classes: