Fix Write Thread does not stop when close pory

pull/228/head
sonbuidev 2019-03-29 14:02:11 +07:00
rodzic 3e889f646f
commit 001e745a4a
2 zmienionych plików z 10 dodań i 1 usunięć

Wyświetl plik

@ -3,13 +3,21 @@ package com.felhr.usbserial;
abstract class AbstractWorkerThread extends Thread {
boolean firstTime = true;
private volatile boolean keep = true;
private volatile Thread workingThread;
void stopThread() {
keep = false;
if (this.workingThread != null) {
this.workingThread.interrupt();
}
}
public final void run() {
while (keep) {
if (!this.keep) {
return;
}
this.workingThread = Thread.currentThread();
while (this.keep && (!this.workingThread.isInterrupted())) {
doRun();
}
}

Wyświetl plik

@ -118,6 +118,7 @@ public class SerialBuffer
} catch (InterruptedException e)
{
e.printStackTrace();
Thread.currentThread().interrupt();
}
}
byte[] dst;