# Synchronize access to array

**URL:** <https://discourse.processing.org/t/synchronize-access-to-array/14895>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [October 23, 2019, 12:02pm UTC](https://discourse.processing.org/t/synchronize-access-to-array/14895 "2019-10-23T12:02:06Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 23, 2019, 8:16pm UTC](https://discourse.processing.org/t/synchronize-access-to-array/14895/4 "2019-10-23T20:16:37Z")

</div>

> [@pcremades](#):
>
> I’m not sure if **serialEvent()** runs in a different Thread, but it seems to be like that.

Most Processing libs that have callback names w/ the word “event” on them are indeed threaded. 🧵

> [@pcremades](#):
>
> I don’t even know if that would be the right way to solve the problem.

There are many ways to workaround threading access/mutation; but I prefer to start w/ the simplest 1s before attempting more advanced techniques. 👨‍💻

If your sketch just needs to refresh the **draw()** when a new data arrives, you can simply use this [**noLoop()**](https://processing.org/reference/noLoop_.html)/[**redraw()**](https://processing.org/reference/redraw_.html) combo: 💡

> [@Map function worked in Processing 2 and early 3.. But broke in 3.5.3. Need guidance](https://discourse.processing.org/t/map-function-worked-in-processing-2-and-early-3-but-broke-in-3-5-3-need-guidance/11371/2):
>
> Mutating the sketch’s main canvas outside the “Animation Thread” crashes the program! boomCallback serialEvent() is run by the Serial’s Thread btW. warningSo even calling something like background() can be fatal! fearfulActually, due to a bad design, any Processing function which depends on color() will get wrong results when they’re multithreading invoked! bugSo any canvas mutating operations should be moved to draw() or called by it. face_with_monocleHere’s a post link for…

---

_[View the full topic](https://discourse.processing.org/t/synchronize-access-to-array/14895)._
