diff --git a/rtos/Thread.cpp b/rtos/Thread.cpp index 20c1a083de..275b1b3c33 100644 --- a/rtos/Thread.cpp +++ b/rtos/Thread.cpp @@ -129,7 +129,11 @@ osStatus Thread::terminate() { _tid = (osThreadId_t)NULL; if (!_finished) { _finished = true; - ret = osThreadTerminate(local_id); + // if local_id == 0 Thread was not started in first place + // and does not have to be terminated + if(local_id != 0) { + ret = osThreadTerminate(local_id); + } } _mutex.unlock(); return ret;