# Concurrency in no-code MachineLogic

**URL:** <https://forum.vention.io/t/concurrency-in-no-code-machinelogic/368>\
**Category:** MachineLogic\
**Created:** [January 30, 2024, 11:01pm UTC](https://forum.vention.io/t/concurrency-in-no-code-machinelogic/368 "2024-01-30T23:01:55Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![maxw](https://yyz2.discourse-cdn.com/flex012/user_avatar/forum.vention.io/maxw/32/23_2.png) [@maxw](https://forum.vention.io/u/maxw)\
**Post date:** [January 30, 2024, 11:01pm UTC](https://forum.vention.io/t/concurrency-in-no-code-machinelogic/368/1 "2024-01-30T23:01:55Z")

</div>

Applications dealing with incoming asynchronous events (e.g. sensors or push buttons) imply concurrency: you want to be able to receive events at all times, while also moving your robots and actuators.

Multi-threading, active loops and interrupts are classic ways of handling concurrency in computer programs, but they can get messy quickly.

MachineLogic (VSE) builds on the js ecosystem, to provide a single-threaded solution to this problem. The magic resides in non-blocking actions. Whenever an action is performed by a device other than the CPU (e.g. a disk drive; or an actuator), the CPU itself immediately returns to its event-handling state, instead of waiting.

As a result, one can program [as many event-triggered sequences as desired](https://forum.vention.io/t/from-simple-imperative-programs-to-event-driven-and-data-driven-machinelogic-basic-idioms/427#h-1-parallel-event-handlers-1), or as many concurrent state machines, almost without thinking about it. A single MachineLogic program can handle multiple conveyors and actuators. No need to worry about data corruption caused by concurrent access to shared data structures, deadlocks caused by tricky concurrency-control patterns, or obscure failures caused by subtle timing issues.

One thing to keep in mind is that long active CPU loops will prevent going back to the event-handling state. Fortunately, long active loops are not too common, and can be avoided easily (e.g. by inserting time outs).

---

_[View the full topic](https://forum.vention.io/t/concurrency-in-no-code-machinelogic/368)._
