diff --git a/concepts/rules.md b/concepts/rules.md index cec390f268..22ce9c9d46 100644 --- a/concepts/rules.md +++ b/concepts/rules.md @@ -21,6 +21,14 @@ openHAB can send a notification to your phone. Other systems may have a concept of _Automations_, _Tasks_, and other terms. In openHAB, rules are used to implement all of these concepts. +Rules can be executed, either when fired by their triggers, or when called explicitly – from a script, another rule, a Main UI widget, etc. +When a rule is fired by its trigger, the execution of one and the same rule does not happen in parallel. +If a rule is triggered for execution, while the rule is currently running, it will be queued and run later. + +When a rule is called explicitly - e.g. from a script, another rule with [`RuleManager.runNow()`](https://www.openhab.org/javadoc/latest/org/openhab/core/automation/rulemanager), or from a Main UI widget - then this rule can be executed in parallel. +That is it can start running, while the same rule is executed at the same time. +In this case there is a need to program protection against race conditions. + ## Parts of a Rule These rules take the high level form of _When \_\_t\_\_ happens, if \_\_c\_\_ then do \_\_a\_\__, diff --git a/configuration/rules-dsl.md b/configuration/rules-dsl.md index 1e364b1e70..9178de866f 100644 --- a/configuration/rules-dsl.md +++ b/configuration/rules-dsl.md @@ -801,7 +801,8 @@ Caveat: Please note the semicolon after the return statement which terminates th ### Concurrency Guard -If a rule triggers on UI events it may be necessary to guard against concurrency. +If a rule is explicitly run from another script, rule, a Main UI widget, etc., instead of a trigger, the rule can be started before the current execution has ended. +It may be necessary to guard against concurrency. ```javascript import java.util.concurrent.locks.ReentrantLock