Skip to content

Commit

Permalink
Merge pull request #228 from t2t-sonbui/fix-write-thread
Browse files Browse the repository at this point in the history
Fix Write Thread does not stop when close port
  • Loading branch information
felHR85 authored Apr 5, 2019
2 parents 41ced7c + 001e745 commit 5eddda9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ synchronized byte[] get()
} catch (InterruptedException e)
{
e.printStackTrace();
Thread.currentThread().interrupt();
}
}
byte[] dst;
Expand Down

0 comments on commit 5eddda9

Please sign in to comment.