How to de-register a running thread in Processing

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.

1 Like

…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

1 Like

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

1 Like