kopia lustrzana https://github.com/felHR85/UsbSerial
Merge pull request #228 from t2t-sonbui/fix-write-thread
Fix Write Thread does not stop when close portpull/240/head
commit
5eddda99e9
|
@ -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