int application_start( void ) { OSStatus err = kNoErr; mico_thread_t handle1; mico_thread_t handle2; /* Create new thread */ err = mico_rtos_create_thread(&handle1, MICO_APPLICATION_PRIORITY, "t1", run1, 500, NULL); err = mico_rtos_create_thread(&handle2, MICO_APPLICATION_PRIORITY, "t2", run2, 500, NULL); mico_rtos_thread_join(&handle1); mico_rtos_thread_join(&handle2); os_thread_log( "t1 t2 exit now" ); return kNoErr; }
int application_start( void ) { OSStatus err = kNoErr; mico_thread_t t_handler = NULL; /* Create a new thread */ err = mico_rtos_create_thread( NULL, MICO_APPLICATION_PRIORITY, "Thread 1", thread_1, 500, NULL ); require_noerr_string( err, exit, "ERROR: Unable to start the thread 1." ); while(1){ /* Create a new thread, and this thread will delete its self and clean its resource */ err = mico_rtos_create_thread( &t_handler, MICO_APPLICATION_PRIORITY, "Thread 2", thread_2, 500, NULL ); require_noerr_string( err, exit, "ERROR: Unable to start the thread 2." ); mico_rtos_thread_join( &t_handler ); } exit: if( err != kNoErr ) os_thread_log( "Thread exit with err: %d", err ); mico_rtos_delete_thread(NULL); return err; }