kopia lustrzana https://github.com/felHR85/UsbSerial
Fix Write Thread does not stop when close pory
rodzic
3e889f646f
commit
001e745a4a
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ public class SerialBuffer
|
|||
} catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
byte[] dst;
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue