threads now pooled
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.tools.Tag;
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
@@ -27,7 +28,7 @@ public class DelayedAction extends ActionList {
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context) {
|
||||
new Thread() {
|
||||
Application.threadPool.execute(new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(delay);
|
||||
@@ -37,7 +38,7 @@ public class DelayedAction extends ActionList {
|
||||
}
|
||||
DelayedAction.super.fire(context);
|
||||
};
|
||||
}.start();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.moving.Train;
|
||||
@@ -38,14 +39,14 @@ public class SetContextTrain extends Action {
|
||||
Id trainId = Id.from(json,REALM_TRAIN);
|
||||
if (isSet(trainId)) {
|
||||
train = Train.get(trainId);
|
||||
if (isNull(train)) new Thread() { // load asynchronously, as referred tile may not be available,yet
|
||||
if (isNull(train)) Application.threadPool.execute(new Thread() { // load asynchronously, as referred tile may not be available,yet
|
||||
public void run() {
|
||||
try {
|
||||
sleep(1000);
|
||||
train = Train.get(trainId);
|
||||
} catch (InterruptedException e) {}
|
||||
};
|
||||
}.start();
|
||||
});
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
@@ -39,14 +40,14 @@ public class SetDisplayText extends TextAction{
|
||||
@Override
|
||||
public Action load(JSONObject json) {
|
||||
if (json.has(DISPLAY)) {
|
||||
new Thread() { // load asynchronously, as referred tile may not be available,yet
|
||||
Application.threadPool.execute(new Thread() { // load asynchronously, as referred tile may not be available,yet
|
||||
public void run() {
|
||||
try {
|
||||
sleep(1000);
|
||||
display = (TextDisplay) plan.get(Id.from(json,DISPLAY), false);
|
||||
} catch (InterruptedException e) {}
|
||||
};
|
||||
}.start();
|
||||
});
|
||||
}
|
||||
return super.load(json);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.srsoftware.web4rail.Application;
|
||||
import de.srsoftware.web4rail.BaseClass;
|
||||
import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
@@ -43,14 +44,14 @@ public class SetRelay extends Action {
|
||||
if (json.has(RELAY)) {
|
||||
String relayId = json.getString(RELAY);
|
||||
relay = BaseClass.get(new Id(relayId));
|
||||
if (isNull(relay)) new Thread() { // if relay not loaded, yet: wait one sec and try again
|
||||
if (isNull(relay)) Application.threadPool.execute(new Thread() { // if relay not loaded, yet: wait one sec and try again
|
||||
public void run() {
|
||||
try {
|
||||
sleep(1000);
|
||||
} catch (InterruptedException e) {}
|
||||
relay = BaseClass.get(new Id(relayId));
|
||||
};
|
||||
}.start();
|
||||
});
|
||||
}
|
||||
if (json.has(Relay.STATE)) state = json.getBoolean(Relay.STATE);
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user