Thread synchronization is defined as a mechanism which ensures that two or more concurrent processes or threads do not simultaneously execute some particular program segment known as critical section.
For example, suppose that there are three processes, namely 1, 2, and 3.