[linuxinput] improve thread names (#9582)

See #9581

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
This commit is contained in:
Thomas Weißschuh 2021-01-03 10:26:09 +01:00 committed by GitHub
parent d9caa46031
commit 217af3704e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View File

@ -63,7 +63,7 @@ public abstract class DeviceReadingHandler extends BaseThingHandler {
logger.warn("Could not read event", e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
}
}, getClass(), getInstanceName());
}, "events", thing);
thread.start();
worker = thread;
}

View File

@ -152,7 +152,7 @@ public class LinuxInputDiscoveryService extends AbstractDiscoveryService {
waitForNewDevices(watcher);
return null;
});
Thread t = Utils.backgroundThread(job, getClass(), null);
Thread t = Utils.backgroundThread(job, "discovery", null);
t.start();
discoveryJob = job;
} else {

View File

@ -14,6 +14,7 @@ package org.openhab.binding.linuxinput.internal;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.thing.Thing;
/**
* Utilities
@ -25,10 +26,10 @@ class Utils {
private Utils() {
}
static Thread backgroundThread(Runnable r, Class<?> clazz, @Nullable String instance) {
String name = LinuxInputBindingConstants.BINDING_ID + " :: " + clazz.getSimpleName();
if (instance != null) {
name += " :: " + instance;
static Thread backgroundThread(Runnable r, String type, @Nullable Thing thing) {
String name = "OH-binding-" + LinuxInputBindingConstants.BINDING_ID + "-" + type;
if (thing != null) {
name += "-" + thing.getUID();
}
Thread t = new Thread(r, name);
t.setDaemon(true);