This is a question on multithreading specifically on how it is to be used in Juce, relating back to my previous post here (http://www.juce.com/forum/topic/gui-unresponsive-even-through-cpu-cores-are-not-too-occupied-likely-i-need).
I often use the feature in Juce, of creating a GUI component (e.g. a Label), with a reference to a value object (Label.getTextValue().referTo(...)), which it is to control.
Then in my model I only keep value objects, and when I programmatically set their value the component is updated, and likewise the component setting the value following user interaction, raises an event and I can react to these changes.
But, above, how is threading dealt with? Is it safe to just ignore threading?
I assume, when programmatically setting a new value to the value object, I need to lock before, and when the Label/Component sets the Value following user input, it needs to do so.
Do I need to also deal with locking/threading whenever I have valueChanged methods that listen to the object?
So for example, a user enters a string using the Label, and in my model, I need to react to that event, so I subscribe to valueChanged(...). When that method is called, is it in the GUI thread, or in my "main thread", assuming that was where the value object was instantiated? If it is in the GUI thread, what do I need to do in valueChanged(...) to react to the change asynchronously from the GUI thread?
Is there an example that I could look at? I saw nothing in the JuceDemo, and I've looked at the analogous example simpleDJ which uses VFlib, but I wanted to see how this is done using Juce alone, so that I better understand the issue before considering to use an additional library.
Searching the forum on this I've only found another question along the same lines, but no answers (http://www.juce.com/forum/topic/best-practice-parameter-changes-and-ui).