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);
     // acquire the Mutex
     cache.lock(sMutexName, -1);
     // do something 
     // release the Mutex