code: public static void releaseLock(EntityManager em, long type, String key) {
          EntityTransaction tx = null;
  
          /* remove the existing lock if it matches the key. */
          try {
              tx = em.getTransaction();
              tx.begin();
  
              GlobalInterlock lock = _findAndRefreshLock(em, type);
  
              if (lock == null) {
                  throw new GlobalInterlockException("No lock of type " + type + " exists for key " + key + ".");
              }
  
              String ref = Long.toHexString(lock.lockTime);
  
              if (ref.equalsIgnoreCase(key)) {
                  em.remove(lock);
                  em.flush();
                  tx.commit();
              } else {
                  throw new GlobalInterlockException("This process doesn't own the type " + type + " lock having key " + key + ".");
              }
          } finally {
              if (tx != null && tx.isActive()) {
                  tx.rollback();
              }
          }
      }
docs: Releases a global lock of the indicated type if the supplied key is a match for the lock.
  
  @param   em    The entity manager factory to use. Cannot be null.
  @param   type  The type of key to release.
  @param   key   The key value obtained from the lock creation.
  
  @throws  GlobalInterlockException  If the lock cannot be released.