FileDocCategorySizeDatePackage
ResourceThrottle.javaAPI DocExample1855Thu Feb 04 16:10:36 GMT 1999None

ResourceThrottle

public class ResourceThrottle extends Object

Fields Summary
private int
resourcecount
private int
resourcemax
Constructors Summary
public ResourceThrottle(int max)


	    
		resourcecount = 0;
		resourcemax = max;
	
Methods Summary
public synchronized voidfreeResource(int numberof)

		resourcecount -= numberof;
		notifyAll();
	
public synchronized voidgetResource(int numberof)

		while (true) {
			if ((resourcecount + numberof) <= resourcemax) {
				resourcecount += numberof;
				break;
			}
			try {
				wait();
			} catch (Exception e) {}
		}