modification to worker to allow integration in other project
This commit is contained in:
@@ -12,24 +12,31 @@ public abstract class Worker implements Runnable {
|
|||||||
protected static final boolean THREAD = false;
|
protected static final boolean THREAD = false;
|
||||||
protected static final int SLEEP = 100;
|
protected static final int SLEEP = 100;
|
||||||
|
|
||||||
|
protected boolean thread = true;
|
||||||
protected boolean interrupt;
|
protected boolean interrupt;
|
||||||
protected boolean run = false;
|
protected boolean run = false;
|
||||||
protected boolean active = false;
|
protected boolean active = false;
|
||||||
protected boolean activate = false;
|
protected boolean activate = false;
|
||||||
protected boolean deactivate = false;
|
protected boolean deactivate = false;
|
||||||
|
|
||||||
public final void start(boolean thread) {
|
public Worker() {}
|
||||||
|
|
||||||
|
public Worker(boolean thread) {
|
||||||
|
this.thread = thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized final void start(boolean thread) {
|
||||||
if (!active) {
|
if (!active) {
|
||||||
activate = true;
|
activate = true;
|
||||||
}
|
}
|
||||||
if (!run) {
|
if (!run) {
|
||||||
run = true;
|
run = true;
|
||||||
if (thread) {
|
if (thread) {
|
||||||
log.debug("Run directly");
|
|
||||||
run();
|
|
||||||
} else {
|
|
||||||
log.debug("Start thread");
|
log.debug("Start thread");
|
||||||
new Thread(this, getClass().getName()).start();
|
new Thread(this, getClass().getName()).start();
|
||||||
|
} else {
|
||||||
|
log.debug("Run directly");
|
||||||
|
run();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
notifyAll();
|
notifyAll();
|
||||||
@@ -37,7 +44,7 @@ public abstract class Worker implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized final void start() {
|
public synchronized final void start() {
|
||||||
start(THREAD);
|
start(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized final void stop() {
|
public synchronized final void stop() {
|
||||||
|
|||||||
Reference in New Issue
Block a user