osSemaphoreId_t exit_sem;void thread_func(void *argument) { // ... 线程工作 ... osSemaphoreRelease(exit_sem); // 通知主线程已完成 osThreadExit();}int main(void) { exit_sem = osSemaphoreNew(1, 0, NULL); osThreadNew(thread_func, NULL, NULL); osSemaphoreAcquire(exit_sem, osWaitForever); // 等待线程结束 // 继续执行...}
|