Compare Mutex and Semaphore in java.



Compare Mutex and Semaphore in java...

Answer / Mukteshwar Yadav

Both are synchronization primitives used for controlling access to shared resources. However, they work differently:nnMutex (Monitor): It is a lock that allows only one thread to access the protected resource at a time. A mutex has a binary lock and can be in two states - locked or unlocked.nSemaphore: It is a generalization of mutexes, which allows multiple threads to access the protected resource if there are sufficient permits available.nIn Java, Mutex is implemented using synchronized blocks or methods, while Semaphores can be created using the java.util.concurrent.Semaphore class.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Why is java architectural neutral?

1 Answers  


Define the term string pool?

1 Answers  


Is finalize() similar to a destructor?

1 Answers  


Can an abstract class have a constructor?

1 Answers   RBS, Wipro,


What is methodological theory?

1 Answers  


what is difference between Interface and abstract class

2 Answers   GCPL,


can we create object for static class in java

14 Answers   IAP Company, IBM, Marlabs, mPortal, TCS,


how to create a jar file in java

1 Answers  


What is difference between throw and throws ?

1 Answers   Cyient,


What is the difference between equals() and == in java?

0 Answers  


What are the 6 boolean operators?

1 Answers  


What is bufferedwriter?

1 Answers  


Categories