Exempel
This is an example program with two threads, one GUI thread, like in all gtkmm programs, and one worker thread. The worker thread is created when you press the Start work button. It is deleted when the work is finished, when you press the Stop work button, or when you press the Quit button.
A Glib::Dispatcher is used for sending notifications from the worker thread to the GUI thread. The ExampleWorker class contains data which is accessed by both threads. This data is protected by a std::mutex. Only the GUI thread updates the GUI.
Compiling and linking a multi-threaded program can require special compiler and linker options. If you use the g++ compiler, add the -pthread option. Other compilers may require other options. If you build with meson, it handles the multi-threading complications for you, if you add dependency('threads').