trunk contents moved to root

This commit is contained in:
Jindra Petřík
2014-05-10 20:50:57 +02:00
parent 1b851e66a8
commit 199a4d0c2b
2296 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
package com.jpexs.proxy;
public class ReusableThread extends Thread
{
private ThreadPool pool = null;
private Runnable runnable = null;
private boolean alive = true;
private long lastrun = 0;
private int used = 0;
public ReusableThread(ThreadPool pool)
{
this.pool = pool;
}
public synchronized void setRunnable(Runnable runnable)
{
this.runnable = runnable;
notify();
}
public synchronized void terminate()
{
alive = false;
notify();
}
public long getLastRunTime()
{
return lastrun;
}
public int useCount()
{
return used;
}
public void run()
{
while (alive)
{
setName("ReusableThread: idle");
while (runnable == null && alive)
{
synchronized (this)
{
try
{
wait();
}
catch (InterruptedException ie)
{
}
}
}
if (alive)
{
setName("ReusableThread: busy");
setPriority(Thread.NORM_PRIORITY);
lastrun = System.currentTimeMillis();
used++;
runnable.run();
runnable = null;
pool.put(this);
}
}
}
}