All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cybergarage.util.Mutex Maven / Gradle / Ivy

Go to download

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();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy