mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-24 02:35:10 +00:00
format proxy code, allow to change swf on the fly
This commit is contained in:
@@ -1,70 +1,57 @@
|
||||
package com.jpexs.proxy;
|
||||
|
||||
public class ReusableThread extends Thread
|
||||
{
|
||||
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 ReusableThread(ThreadPool pool) {
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
public synchronized void setRunnable(Runnable runnable)
|
||||
{
|
||||
this.runnable = runnable;
|
||||
notify();
|
||||
public synchronized void setRunnable(Runnable runnable) {
|
||||
this.runnable = runnable;
|
||||
notify();
|
||||
}
|
||||
|
||||
public synchronized void terminate()
|
||||
{
|
||||
alive = false;
|
||||
notify();
|
||||
public synchronized void terminate() {
|
||||
alive = false;
|
||||
notify();
|
||||
}
|
||||
|
||||
public long getLastRunTime()
|
||||
{
|
||||
return lastrun;
|
||||
public long getLastRunTime() {
|
||||
return lastrun;
|
||||
}
|
||||
|
||||
public int useCount()
|
||||
{
|
||||
return used;
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user