In Multi-thread program, race condition can occur when at least two or more threads try to access same resource at the same time. Multiple thread synchronization methods exist like mutex, conditional variable, semaphore etc.
If critical section is being accessed in a synchronized or control manner the it is known as thread safe.
OS takes care of its own implementation and user or programmer can use utilities or methods provided by OS to make their program thread safe.