import java.util.Random;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import org.apache.commons.lang.StringUtils;
+import org.openhab.core.common.NamedThreadFactory;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
protected List<ApplianceStatusListener> applianceStatusListeners = new CopyOnWriteArrayList<>();
protected ScheduledFuture<?> pollingJob;
- protected ScheduledFuture<?> eventListenerJob;
+ protected ExecutorService executor;
+ protected Future<?> eventListenerJob;
protected List<HomeDevice> previousHomeDevices = new CopyOnWriteArrayList<>();
logger.debug("Scheduling the Miele event listener job");
if (eventListenerJob == null || eventListenerJob.isCancelled()) {
- eventListenerJob = scheduler.schedule(eventListenerRunnable, 0, TimeUnit.SECONDS);
+ executor = Executors.newSingleThreadExecutor(new NamedThreadFactory("binding-miele"));
+ eventListenerJob = executor.submit(eventListenerRunnable);
}
}
eventListenerJob.cancel(true);
eventListenerJob = null;
}
+ if (executor != null) {
+ executor.shutdownNow();
+ executor = null;
+ }
}
}