format proxy code, allow to change swf on the fly

This commit is contained in:
honfika@gmail.com
2014-09-01 16:56:55 +02:00
parent 8325d07b24
commit ed53ba9d0f
37 changed files with 1847 additions and 2267 deletions

View File

@@ -2,52 +2,44 @@ package com.jpexs.proxy;
import java.util.*;
public class ThreadPool implements Cleanable
{
public class ThreadPool implements Cleanable {
private String name;
private Vector pool = new Vector();
public ThreadPool(String name)
{
this.name = name;
public ThreadPool(String name) {
this.name = name;
}
public synchronized ReusableThread get()
{
ReusableThread rt = null;
public synchronized ReusableThread get() {
ReusableThread rt = null;
if (pool.size() > 0)
{
rt = (ReusableThread)pool.firstElement();
pool.removeElement(rt);
}
if (pool.size() > 0) {
rt = (ReusableThread) pool.firstElement();
pool.removeElement(rt);
}
if (rt == null)
{
rt = new ReusableThread(this);
rt.start();
}
if (rt == null) {
rt = new ReusableThread(this);
rt.start();
}
return rt;
return rt;
}
public synchronized void put(ReusableThread rt)
{
pool.addElement(rt);
public synchronized void put(ReusableThread rt) {
pool.addElement(rt);
}
public synchronized void clean()
{
long now = System.currentTimeMillis();
for (Enumeration e = pool.elements(); e.hasMoreElements(); )
{
ReusableThread rt = (ReusableThread) e.nextElement();
if (now - rt.getLastRunTime() >= 30000)
{
rt.terminate();
pool.removeElement(rt);
}
}
public synchronized void clean() {
long now = System.currentTimeMillis();
for (Enumeration e = pool.elements(); e.hasMoreElements();) {
ReusableThread rt = (ReusableThread) e.nextElement();
if (now - rt.getLastRunTime() >= 30000) {
rt.terminate();
pool.removeElement(rt);
}
}
}
}