How do I create a cluster-wide named mutex?

To create a cluster-wide, named mutex, simply lock a key in a cache with an infinite wait time. Note that a key can be locked even though the key does not actually exist in the cache. This example implements a non-recursive mutex.

String sMutexName = "myNamedMutex";
   NamedCache cache = CacheFactory.getCache(sCacheName);
 
   try
     {
     // acquire the Mutex
     cache.lock(sMutexName, -1);
 
     // do something 
     [COH33UG:...]
     }
   finally
     {
     // release the Mutex
     cache.unlock(sMutexName); 
     }