How do you manage task synchronization and prevent race conditions in a multi-threaded RTOS environment?