use Thread.isAlive()

This commit is contained in:
Milos Kozak 2018-07-20 17:52:31 +02:00
parent cfee405914
commit ab70d5b67d

View file

@ -392,10 +392,10 @@ public class IobCobCalculatorPlugin extends PluginBase {
time = roundUpTime(previous);
AutosensData data = autosensDataTable.get(time);
if (data != null) {
//log.debug(">>> getAutosensData Cache hit " + data.log(time));
//log.debug(">>> AUTOSENSDATA Cache hit " + data.toString());
return data;
} else {
// log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString());
//log.debug(">>> AUTOSENSDATA Cache miss " + new Date(time).toLocaleString());
return null;
}
}
@ -403,13 +403,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
@Nullable
public AutosensData getLastAutosensDataSynchronized(String reason) {
if (thread != null && thread.getState() != Thread.State.TERMINATED) {
log.debug("getLastAutosensDataSynchronized is waiting for calculation thread: " + reason);
if (thread != null && thread.isAlive()) {
log.debug("AUTOSENSDATA is waiting for calculation thread: " + reason);
try {
thread.join(5000);
} catch (InterruptedException ignored) {
}
log.debug("getLastAutosensDataSynchronized finished waiting for calculation thread: " + reason);
log.debug("AUTOSENSDATA finished waiting for calculation thread: " + reason);
}
synchronized (dataLock) {
return getLastAutosensData(reason);
@ -464,6 +464,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
log.debug("AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time));
return null;
} else {
log.debug("AUTOSENSDATA (" + reason + ") " + data.toString());
return data;
}
}