# How to use more than 50 allowed Threads?

**URL:** <https://forum.universal-robots.com/t/how-to-use-more-than-50-allowed-threads/5354>\
**Category:** URScript\
**Created:** [October 17, 2019, 9:47am UTC](https://forum.universal-robots.com/t/how-to-use-more-than-50-allowed-threads/5354 "2019-10-17T09:47:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon71387359](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@anon71387359](https://forum.universal-robots.com/u/anon71387359)\
**Post date:** [October 17, 2019, 9:47am UTC](https://forum.universal-robots.com/t/how-to-use-more-than-50-allowed-threads/5354/1 "2019-10-17T09:47:51Z")

</div>

Dear all,

I am using a thread to monitor an input signal whenever it is required in the program sequence.  
The thread is created in Installation Node and called from the Program Node when required.

As i am calling and killing the thread in the same URCap, the thread is created as many times the URCap is used in the program sequence.

The current situation is i could use only 50 one particualr URCap in the program as i get an error “Cannot create thread: All 50 allowed threads are used by the program”.

I would like to use more than 50 URCaps and at the same time use the thread to monitor the input signal when required in the program.  
How do i solve this problem?

Thank you, in advance for your help.

---

<div class="post-metadata">

**Author:** ![mmi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mmi/32/691_2.png) [@mmi](https://forum.universal-robots.com/u/mmi)\
**Post date:** [October 21, 2019, 8:11am UTC](https://forum.universal-robots.com/t/how-to-use-more-than-50-allowed-threads/5354/2 "2019-10-21T08:11:14Z")

</div>

There is hard limit of 50 threads in controller.  
Could you post script code example?  
Potentially you could create a monitoring thread in installation contribution, and then communicate status through global variable.

---

<div class="post-metadata">

**Author:** ![anon71387359](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@anon71387359](https://forum.universal-robots.com/u/anon71387359)\
**Post date:** [October 21, 2019, 11:22am UTC](https://forum.universal-robots.com/t/how-to-use-more-than-50-allowed-threads/5354/3 "2019-10-21T11:22:05Z")

</div>

Thanks a million.

Communicating just by using the ‘global variable’ solved the problem.

---

<div class="post-metadata">

**Author:** ![anon38799190](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anon38799190](https://forum.universal-robots.com/u/anon38799190)\
**Post date:** [July 11, 2022, 11:33am UTC](https://forum.universal-robots.com/t/how-to-use-more-than-50-allowed-threads/5354/4 "2022-07-11T11:33:42Z")

</div>

Hi!

I’ve ran in the same issue as OP. Can you elaborate a bit more on what “monitoring thread in installation contribution is” and how a global variable solves the issue?

Thanks!

---

<div class="post-metadata">

**Author:** ![mmi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mmi/32/691_2.png) [@mmi](https://forum.universal-robots.com/u/mmi)\
**Post date:** [October 31, 2022, 1:27pm UTC](https://forum.universal-robots.com/t/how-to-use-more-than-50-allowed-threads/5354/5 "2022-10-31T13:27:05Z")

</div>

URCap should create single thread monitoring input, and make it available on global variable to all script contributions.  
Installation contribution is always called exactly once no matter how many urcap nodes are in the program. Here is an example:

```
global input1_status = 0
global input2_status = 0
...
def urcap_monitor_thread():
    input1_status = read_custom_input(1)
    input2_status = read_custom_input(2)
   ...
end

```

Node contribution is added every time urcap node is added to the program:

```
# action dependent on last input state
if input1_status == 1:
    ...
elif input1_status == 2:
    ...
end

```
