# ExecutionEngine question

**URL:** <https://forum.inductiveautomation.com/t/executionengine-question/7826>\
**Category:** Module Development\
**Created:** [January 13, 2014, 6:08pm UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826 "2014-01-13T18:08:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcaan](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@alcaan](https://forum.inductiveautomation.com/u/alcaan)\
**Post date:** [January 13, 2014, 6:08pm UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826/1 "2014-01-13T18:08:44Z")

</div>

I would like to know what is the difference between using the ExequtionManager you can get from the context and the implementation BasicExecutionEngine. And is there is some documentation from the later apart from the docs. We have the problem that when restarting a module, using the BasicExectuitonEngine, the threads from it are not closing and remain there untili you restart Ignition.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 13, 2014, 6:13pm UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826/2 "2014-01-13T18:13:18Z")

</div>

Do you really need your own BasicExecutionEngine or can you use the shared one? Are you shutting down your BasicExecutionEngine? Are you using daemon threads?

---

<div class="post-metadata">

**Author:** ![alcaan](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@alcaan](https://forum.inductiveautomation.com/u/alcaan)\
**Post date:** [January 13, 2014, 6:17pm UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826/3 "2014-01-13T18:17:54Z")

</div>

I don’t need to use my own engine. Is better to use the shared one. We are not closing the engine at the end. I see the daemon thread at the docs but I don’t know what behaviour it has.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 13, 2014, 6:19pm UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826/4 "2014-01-13T18:19:32Z")

</div>

Well, use the shared one if you can, and if you decide to use your own you need to shut it down when your module’s shutdown hook runs.

---

<div class="post-metadata">

**Author:** ![alcaan](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@alcaan](https://forum.inductiveautomation.com/u/alcaan)\
**Post date:** [January 14, 2014, 11:25am UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826/5 "2014-01-14T11:25:55Z")

</div>

Now I’m using the method BasicExecutionEngine.shutdown() during the shutdown of the module and seems to work fine. Is this correct? Would love to know if there is some info that explains the diferences between using the ExecutionEngine of the context and one of your own. Thanks!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 14, 2014, 4:13pm UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826/6 "2014-01-14T16:13:26Z")

</div>

If you use your own, shut it down during your module shutdown, but don’t shut down the shared one from the context.

The only real difference is that when you create your own it adds (yet another) thread pool to the system. If you’re module is going to be using that thread pool very heavily it might be appropriate to create your own. Otherwise using the shared one is fine.

---

<div class="post-metadata">

**Author:** ![alcaan](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@alcaan](https://forum.inductiveautomation.com/u/alcaan)\
**Post date:** [January 14, 2014, 4:32pm UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826/7 "2014-01-14T16:32:46Z")

</div>

Ok. Thank you. I was using the shared one in one module and of course didn’t close it (because is a resource of the system and other threads are running). But other developer, using my code as starting point, started a new module creating its on executionEngine. Of course, he didn’t close it in the shutdown because I dindn’t close the shared in my code, so there started the problem with the threads. And we had this discussion about using the shared or using the other, but we couldn’t settle the matter because the lack of info. Can you tell us how much threads is considered heavily used? We have almost 20 listeners that start an executeOnce task, and in a minute each listener can be called between 2-4 times.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 14, 2014, 4:39pm UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826/8 "2014-01-14T16:39:25Z")

</div>

I think it’s probably fine for you to create your own. You can also use the standard Java ExecutorService/ScheduledExecutorService instead of the BasicExecutionEngine, which is just wrapping one of those anyway.

---

<div class="post-metadata">

**Author:** ![alcaan](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@alcaan](https://forum.inductiveautomation.com/u/alcaan)\
**Post date:** [January 14, 2014, 5:08pm UTC](https://forum.inductiveautomation.com/t/executionengine-question/7826/9 "2014-01-14T17:08:10Z")

</div>

Thank you. I will take a look to the java docs to decide what solution is the best.
