FileDocCategorySizeDatePackage
ResourceThrottle.javaAPI DocExample1098Tue Jan 28 17:14:28 GMT 1997None

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) {}
          }