Continually try to force-interrupt an event thread if it does not join in a timely fashion

This commit is contained in:
Will Hedgecock 2022-02-14 11:51:29 -06:00
parent a9444ffbad
commit faffe075c8
1 changed files with 7 additions and 5 deletions

View File

@ -2,7 +2,7 @@
* SerialPort.java
*
* Created on: Feb 25, 2012
* Last Updated on: Jan 28, 2022
* Last Updated on: Feb 14, 2022
* Author: Will Hedgecock
*
* Copyright (C) 2012-2022 Fazecast, Inc.
@ -1765,10 +1765,12 @@ public final class SerialPort
try
{
serialEventThread.join(500);
if (serialEventThread.isAlive())
serialEventThread.interrupt();
serialEventThread.join();
do
{
serialEventThread.join(500);
if (serialEventThread.isAlive())
serialEventThread.interrupt();
} while (serialEventThread.isAlive());
}
catch (InterruptedException e) { Thread.currentThread().interrupt(); }
serialEventThread = null;