use thread.join
This commit is contained in:
parent
d17ffc334d
commit
cfee405914
1 changed files with 8 additions and 8 deletions
|
@ -403,9 +403,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public AutosensData getLastAutosensDataSynchronized(String reason) {
|
public AutosensData getLastAutosensDataSynchronized(String reason) {
|
||||||
while (thread != null && thread.getState() != Thread.State.TERMINATED) {
|
if (thread != null && thread.getState() != Thread.State.TERMINATED) {
|
||||||
SystemClock.sleep(100);
|
log.debug("getLastAutosensDataSynchronized is waiting for calculation thread: " + reason);
|
||||||
log.debug("getLastAutosensDataSynchronized is waiting for calculation thread");
|
try {
|
||||||
|
thread.join(5000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
log.debug("getLastAutosensDataSynchronized finished waiting for calculation thread: " + reason);
|
||||||
}
|
}
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
return getLastAutosensData(reason);
|
return getLastAutosensData(reason);
|
||||||
|
@ -505,14 +509,10 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
|
|
||||||
public AutosensResult detectSensitivityWithLock(long fromTime, long toTime) {
|
public AutosensResult detectSensitivityWithLock(long fromTime, long toTime) {
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
return detectSensitivity(fromTime, toTime);
|
return ConfigBuilderPlugin.getActiveSensitivity().detectSensitivity(fromTime, toTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static AutosensResult detectSensitivity(long fromTime, long toTime) {
|
|
||||||
return ConfigBuilderPlugin.getActiveSensitivity().detectSensitivity(fromTime, toTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JSONArray convertToJSONArray(IobTotal[] iobArray) {
|
public static JSONArray convertToJSONArray(IobTotal[] iobArray) {
|
||||||
JSONArray array = new JSONArray();
|
JSONArray array = new JSONArray();
|
||||||
for (int i = 0; i < iobArray.length; i++) {
|
for (int i = 0; i < iobArray.length; i++) {
|
||||||
|
|
Loading…
Reference in a new issue