What is mutex and Semaphore in Java
Mutex and Semaphore in Java both used to provide mutual exclusion for critical section of code but they are completely different to each other. If you want a block of code can be only executed by one thread at a given time you usually lock that portion of code using a mutext which is achieved by using synchronized keyowrord in Java.
Mutex and Semaphore in Java both used to provide mutual exclusion for critical section of code but they are completely different to each other. If you want a block of code can be only executed by one thread at a given time you usually lock that portion of code using a mutext which is achieved by using synchronized keyowrord in Java.