# FR: Thread-safe \`repaint\`

**URL:** <https://forum.juce.com/t/fr-thread-safe-repaint/65711>\
**Category:** Feature Requests\
**Created:** [April 2, 2025, 7:15am UTC](https://forum.juce.com/t/fr-thread-safe-repaint/65711 "2025-04-02T07:15:43Z")\
**Posts on this page:** 1\
**Showing post:** 28

<div class="post-metadata">

**Author:** ![zsliu98](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zsliu98/32/22502_2.png) [@zsliu98](https://forum.juce.com/u/zsliu98)\
**Post date:** [April 7, 2025, 2:36pm UTC](https://forum.juce.com/t/fr-thread-safe-repaint/65711/28 "2025-04-07T14:36:58Z")

</div>

CAS/RCU seemed like a solution to me at the first glance. However, I soon found that I could not use those techniques. Because of [Make isThisTheMessageThread() lock free](https://forum.juce.com/t/make-isthisthemessagethread-lock-free/62620), I cannot tell whether `parameterChanged()` is called from the audio thread (in a lock-free way). If it is from the audio thread, I should update immediately (because CAS/RCU both allocates); If it is from the message thread, I should use CAS/RCU. And overall it would make things too complicated.

Since JUCE 9 may have the sample-accurate automation, I would expect things become different so that we can deal with parameter changes in the audio thread. As @eyalamir suggests, perhaps I should also write my own `ParameterAttachment` with timer/vblank to get rid of those locks.

---

_[View the full topic](https://forum.juce.com/t/fr-thread-safe-repaint/65711)._
