# How to de-register a running thread in Processing

**URL:** <https://discourse.processing.org/t/how-to-de-register-a-running-thread-in-processing/33337>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [November 5, 2021, 3:56pm UTC](https://discourse.processing.org/t/how-to-de-register-a-running-thread-in-processing/33337 "2021-11-05T15:56:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avong](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@avong](https://discourse.processing.org/u/avong)\
**Post date:** [November 5, 2021, 3:56pm UTC](https://discourse.processing.org/t/how-to-de-register-a-running-thread-in-processing/33337/1 "2021-11-05T15:56:14Z")

</div>

Permit me to ask once again.  
I have read and understand how to register thread using the "thread( " “)” function.  
but, in all the tutorials, i did not see where i can stop a running thread.

is there any helping hand?  
i need to run a blocking function based on certain condition, but i do not want the function to affect other functions.

---

<div class="post-metadata">

**Author:** ![Brahvim](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/brahvim/32/14756_2.png) [@Brahvim](https://discourse.processing.org/u/Brahvim)\
**Post date:** [November 6, 2021, 3:36am UTC](https://discourse.processing.org/t/how-to-de-register-a-running-thread-in-processing/33337/2 "2021-11-06T03:36:19Z")

</div>

…if I understand your question correctly, well… you could use a `boolean` to check if the thread needs to stop. If so, simply `return;` from the `function` you ‘registered’.

…of course this only works if your thread has a looping construct, otherwise…you’ll have to check in the code for the thread, again and again, if it has been stopped.

The best solution to this problem would be to use a standard Java thread, and call `threadObject.join()` on it. You can look up a tutorial on how to make a thread using pure Java, it’s actually quite simple if you try to understand it.

Immediate edit: here is a tutorial I use as a reference: [Multithreading in Java - GeeksforGeeks](https://www.geeksforgeeks.org/multithreading-in-java/)

---

<div class="post-metadata">

**Author:** ![avong](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@avong](https://discourse.processing.org/u/avong)\
**Post date:** [November 6, 2021, 6:11am UTC](https://discourse.processing.org/t/how-to-de-register-a-running-thread-in-processing/33337/3 "2021-11-06T06:11:12Z")

</div>

Ok.  
I will from the reference you shared.  
Thanks.
