how to restart a thread?

Hi.

 

I need, during the execution of the application, to be able to restart a thread. I am trying to do it in the following way:

while (1) {

if (sDrivers.niReset==2) {
    status=tx_thread_reset(&http_server_thread);
    if (status==TX_SUCCESS)
      sDrivers.niReset=0;
}

if (sDrivers.niReset==1) {
   status=tx_thread_terminate(&http_server_thread);
    if (status==TX_SUCCESS)
        sDrivers.niReset=2;
}

tx_thread_sleep(100);

}

but it doesn't work properly for me.


What would be the correct way to do it?

 

Thank you.

Regards