# Timers - Wait For Completion

**URL:** <https://community.openhab.org/t/timers-wait-for-completion/94544>\
**Category:** Scripts & Rules\
**Created:** [March 14, 2020, 10:37am UTC](https://community.openhab.org/t/timers-wait-for-completion/94544 "2020-03-14T10:37:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![delid4ve](https://community.openhab.org/user_avatar/community.openhab.org/delid4ve/32/48527_2.png) [@delid4ve](https://community.openhab.org/u/delid4ve)\
**Post date:** [March 14, 2020, 10:37am UTC](https://community.openhab.org/t/timers-wait-for-completion/94544/1 "2020-03-14T10:37:13Z")

</div>

In one of my rules a loop through all items (for each) and change states.  
This is contained in a timer which I reschedule after x seconds.  
What I’ve found is that dependant on current system load, if changing all the states takes longer than x then it enters as race condition.  
So if x is set at 3 seconds, it takes 4 seconds to complete and I let it run for 1 minute then when I cancel the timer it’s still processing state changes for 20 seconds (undesirable).  
So it seems the built in timer doesn’t use scheduleAtFixedDelay and let all child methods (from each binding) complete before rescheduling.

On mobile at moment so now access to the code blocks to post up but wondered if someone has anyway to negate this

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [March 14, 2020, 10:44am UTC](https://community.openhab.org/t/timers-wait-for-completion/94544/2 "2020-03-14T10:44:08Z")

</div>

> [@delid4ve](#):
>
> So it seems the built in timer doesn’t use scheduleAtFixedDelay

That is correct. createTimer targets a fixed datetime instant.

It sounds like something that requires event based thinking. When X completes start Y.

---

<div class="post-metadata">

**Author:** ![system](https://community-openhab-org.s3-eu-central-1.amazonaws.com/original/2X/6/6a52f2ac5d00e4c7b50471a354b3a9221188be90.png) [@system](https://community.openhab.org/u/system)\
**Post date:** [April 25, 2020, 2:44am UTC](https://community.openhab.org/t/timers-wait-for-completion/94544/3 "2020-04-25T02:44:09Z")

</div>

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.
