use Thread.isAlive()
This commit is contained in:
parent
cfee405914
commit
ab70d5b67d
1 changed files with 6 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue