org.cybergarage.util.Mutex Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of upnp-stack Show documentation
Show all versions of upnp-stack Show documentation
A pure Java Open Source implementation of the UPnP stack for JDK 1.4 or above
The newest version!
/******************************************************************
*
* CyberUtil for Java
*
* Copyright (C) Satoshi Konno 2002-2004
*
* File: Mutex.java
*
* Revision:
*
* 06/19/04
* - first revision.
*
******************************************************************/
package org.cybergarage.util;
public class Mutex
{
private boolean syncLock;
////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////
public Mutex()
{
syncLock = false;
}
////////////////////////////////////////////////
// lock
////////////////////////////////////////////////
public synchronized void lock()
{
while(syncLock == true) {
try {
wait();
}
catch (Exception e) {
Debug.warning(e);
};
}
syncLock = true;
}
public synchronized void unlock()
{
syncLock = false;
notifyAll();
}
}