Merge pull request #228 from t2t-sonbui/fix-write-thread

Fix Write Thread does not stop when close port
pull/240/head
Felipe Herranz 2019-04-06 00:39:47 +02:00 zatwierdzone przez GitHub
commit 5eddda99e9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
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;