How to know if a parameter has been changed by automation or by the plugin?

Hello,
i have a parameter
juce::AudioParameterInt* P
When it is changed, the function parameterValueChanged () is called.
In this function is it possible to know if the change has been done by automation (the DAW) or by the plugin (myself somewhere else in the code)?
Thanks,
Frédéric.

Depending on how you listen to the parameter (sync or async) you might be able to identify it by checking if the current thread is the message thread.

Thank you very much for your answer.
And if the current thread is not the message thread, what is the usual way to do thread safe operations with the variables of the plugin? using a mutex for example or using atomic variables etc?

after some plugin releases i decided to subclass juce::AudioProcessorParameter and make my own parameter class in an attempt to be able to add features to parameters at the very source of them and it has already helped me multiple times coming up with a solution that seemed more structured than outsourcing the problem to other places in the code. i see potential with this problem as well, because if you imagine making your own Component for modifying parameter values, like knobs, button, xypads, envelope editors etc, you can imagine how in the mouse functions it would just not call setValueNotifyingHost, but a new method, like setValueFromGUI and this method would call setValueNotifyingHost and then trigger an event or maybe set some bool to true in order to show some other part of the code that a certain value change came from the GUI (or the message thread in general). my suggestion is a bit of work, like an entire parameter class and GUI components, but i think it’s worth it