Semaphore is another way of synchronizing threads for solving the producer-consumer problem or guarding a critical section. Ignite's distributed semaphore data structure is IgniteSemaphore.
We can define a semaphore using the following syntax:
IgniteSemaphore semaphore = ignite.semaphore( "mySemaphore", // semaphore name. 20, // permits. true, // Release acquired permits if node, that owned them, left topology. true // Create if it doesn't exist.);
IgniteSemaphore has two important methods:
- acquire()