9 years, 6 months ago.

Stopping the operation of a thread

Hello,

I would like to know which command is used to stop the operation of a thread. Use two thread in my program, and specific points of my program, I would kill them.

Thank you. Carlos Alberto.

Question relating to:

5 Answers

4 years, 3 months ago.

Does exists any way to terminate running thread from another running thread?

THX.

9 years, 3 months ago.

Hey Carlos. I have the same problem. I want to start executing a function in a thread and also be able to restart (stop and start it again) the same function executing also in a thread, doing it e.g for 50 times.

Actually i create and strat my thread by new-operator (pointer) and after executing or after using the terminate-method i kill the stuff with delete. The problem is i am able to do this just for 11 times (although the maximum number of useable threads is set to 7 in rtos library). After 11th execution i cant create a new thread.

So, how have you solved your software problem?

Maybe here is someone other who can help me?

Regards.

Andreas

Hi Andreas,

I solved my problem by managing the shared use of a single resource (serial port). View in: Mutex -> https://mbed.org/handbook/RTOS

I could not stop and start the tread.

Sorry for the lack of response!

Best Regards.

Carlos Alberto

posted by Carlos Alberto Nascimento Filho 12 Mar 2013
6 years, 3 months ago.

/media/uploads/oceam2/madrid01.jpg

An example how to start and stop a tread:

9 years, 6 months ago.

Hi Carlos,

Take a look at the terminate method:

your_thread_1.terminate()

Cheers, Sam

Thank You!

posted by Carlos Alberto Nascimento Filho 05 Dec 2012

Is it possible to terminate running thread from another running thread?

THX

posted by Rene Klauco 27 Feb 2018
9 years, 6 months ago.

Ok, your_thread_1.terminate (), kills the thread.

And to return to run again?

Thank You. Carlos Alberto.