Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

RemoveDataListener 500ms thread timeout #520

Closed saravanan-13 closed 1 year ago

saravanan-13 commented 1 year ago

removeDataListener function is waiting for the listener thread to be closed, But it is always getting interrupted after 500ms, causing a delay of 500ms during every listener add and remove interaction.

try { serialEventThread.join(500); if (serialEventThread.isAlive()) serialEventThread.interrupt(); serialEventThread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } serialEventThread = null;

hedgecrw commented 1 year ago

If the serialEventThread is not returning for 500 ms, but is successfully returning after being manually interrupted, this sounds like most likely, the code within the serialEvent() function of your data listener is doing something that is blocking forever (or for a really long time). Can you check this function and verify that you are not making any blocking calls within it? Ideally, posting this function would be helpful. Thanks!

hedgecrw commented 1 year ago

Closing due to inactivity, not a bug.