home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www.http;
-
- import java.util.Stack;
- import java.util.Vector;
-
- class ClientVector extends Stack implements Runnable {
- private int num;
- private KeepAliveCache cache;
- private KeepAliveKey key;
- HttpClient[] inUse;
- private int nap;
-
- ClientVector(KeepAliveCache var1, KeepAliveKey var2, int var3) {
- this.cache = var1;
- this.key = var2;
- this.nap = var3;
- this.inUse = new HttpClient[KeepAliveCache.MAXCONNS];
- }
-
- synchronized HttpClient get() {
- if (((Stack)this).empty()) {
- return null;
- } else {
- HttpClient var1 = (HttpClient)((Stack)this).pop();
- if (this.inUse.length == this.num) {
- HttpClient[] var2 = new HttpClient[this.inUse.length * 2];
- System.arraycopy(this.inUse, 0, var2, 0, this.inUse.length);
- this.inUse = var2;
- }
-
- this.inUse[this.num++] = var1;
- return var1;
- }
- }
-
- synchronized void put(HttpClient var1) {
- if (this.num > 0) {
- --this.num;
- }
-
- for(int var2 = 0; var2 < this.inUse.length; ++var2) {
- if (this.inUse[var2] == var1) {
- this.inUse[var2] = null;
- break;
- }
- }
-
- ((Stack)this).push(var1);
- this.notifyAll();
- }
-
- public void run() {
- int var1;
- do {
- try {
- Thread.sleep((long)this.nap);
- } catch (InterruptedException var13) {
- }
-
- synchronized(this){}
-
- try {
- for(int var5 = 0; var5 < ((Vector)this).size(); ++var5) {
- HttpClient var2 = (HttpClient)((Vector)this).elementAt(var5);
- var2.closeServer();
- }
-
- ((Vector)this).removeAllElements();
- if (this.num == 0) {
- this.cache.removeVector(this.key);
- return;
- }
- } catch (Throwable var14) {
- throw var14;
- }
-
- for(int var3 = 0; var3 < this.inUse.length; ++var3) {
- HttpClient var15;
- if ((var15 = this.inUse[var3]) != null && var15.kas.hurry()) {
- this.put(var15);
- }
- }
-
- synchronized(this){}
-
- try {
- var1 = this.num + ((Vector)this).size();
- } catch (Throwable var12) {
- throw var12;
- }
- } while(var1 > 0);
-
- this.cache.removeVector(this.key);
- }
- }
-