# EZBlock threading?

**URL:** <https://forum.sunfounder.com/t/ezblock-threading/711>\
**Category:** Robotic kit for Raspberry Pi\
**Created:** [December 23, 2023, 2:47pm UTC](https://forum.sunfounder.com/t/ezblock-threading/711 "2023-12-23T14:47:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![schuemie](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@schuemie](https://forum.sunfounder.com/u/schuemie)\
**Post date:** [December 23, 2023, 2:47pm UTC](https://forum.sunfounder.com/t/ezblock-threading/711/1 "2023-12-23T14:47:33Z")

</div>

I’m playing with EZBlock and our Picar-X, very cool!

However, my main loop is getting a bit slow, and I’d like to offload some operations to a separate thread. I see blocks for threading in EZBlock Studio, but no documentation on how to use them. Could you provide an example?

(I am an experienced programmer and understand multi-threading. I just don’t understand the syntax in EZBlock)

---

<div class="post-metadata">

**Author:** ![SunFounder\_Moderator](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SunFounder\_Moderator](https://forum.sunfounder.com/u/SunFounder_Moderator)\
**Post date:** [December 25, 2023, 7:18am UTC](https://forum.sunfounder.com/t/ezblock-threading/711/2 "2023-12-25T07:18:41Z")

</div>

Ezblock’s Block is directly escaped into Python and then run. thread is python threading. this is a simple example:

 ![122502](https://canada1.discourse-cdn.com/flex029/uploads/sunfounder/original/1X/8a688a29ce581fd2f306b94df4250bd142c1bf2b.png)  
Note that Threading Method is a function name that is filled in directly as a string. It should correspond to the function name below. Also note that the function name should conform to the python function naming convention.

---

<div class="post-metadata">

**Author:** ![schuemie](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@schuemie](https://forum.sunfounder.com/u/schuemie)\
**Post date:** [December 28, 2023, 11:31am UTC](https://forum.sunfounder.com/t/ezblock-threading/711/3 "2023-12-28T11:31:56Z")

</div>

Thanks! However, I think I’m still doing something wrong. I replicated your example:

> **[Screenshot\_20231228-113819\_EzBlock Studio.jpg](https://drive.google.com/file/d/11p57FMKf4dPFARlsxVhdBh0A_FJ-v_ZK/view?usp=drivesdk)**
>
> Google Drive file.

But when I run it I get:

> **[Screenshot\_20231228-113905\_EzBlock Studio.jpg](https://drive.google.com/file/d/11qH1_3c9sU0E2U4w4DtLdeWFvDzESUji/view?usp=drivesdk)**
>
> Google Drive file.

I’m running EZBlock Studio 1.2.4 on Android.

---

<div class="post-metadata">

**Author:** ![SunFounder\_Moderator](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SunFounder\_Moderator](https://forum.sunfounder.com/u/SunFounder_Moderator)\
**Post date:** [December 29, 2023, 9:11am UTC](https://forum.sunfounder.com/t/ezblock-threading/711/4 "2023-12-29T09:11:26Z")

</div>

I’m very sorry for the incorrect positional organization, please follow as shown.

 ![122901](https://canada1.discourse-cdn.com/flex029/uploads/sunfounder/original/1X/0b62cde602d9adb7187e5f88ff146d53919d7b55.png)

---

<div class="post-metadata">

**Author:** ![schuemie](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@schuemie](https://forum.sunfounder.com/u/schuemie)\
**Post date:** [December 31, 2023, 10:53am UTC](https://forum.sunfounder.com/t/ezblock-threading/711/5 "2023-12-31T10:53:35Z")

</div>

Got it, thanks!

(I put the ultrasound sensor in its own thread. It was taking quite some time per cycle, probably just waiting for some interrupt of the return signall

---

<div class="post-metadata">

**Author:** ![SunFounder\_Moderator](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SunFounder\_Moderator](https://forum.sunfounder.com/u/SunFounder_Moderator)\
**Post date:** [January 2, 2024, 2:49am UTC](https://forum.sunfounder.com/t/ezblock-threading/711/6 "2024-01-02T02:49:45Z")

</div>

I don’t quite understand your question, what kind of problem are you encountering?  
Please provide us with a picture of the problem, or send us the code block you need to execute, so that we can analyze and solve the problem.

---

<div class="post-metadata">

**Author:** ![schuemie](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@schuemie](https://forum.sunfounder.com/u/schuemie)\
**Post date:** [January 7, 2024, 11:53am UTC](https://forum.sunfounder.com/t/ezblock-threading/711/7 "2024-01-07T11:53:24Z")

</div>

Sorry for the confusion. Putting the function at the top solved the problem, and all is working as intended.
