3

I believe I have researched answers to similar problems and have not found the answer to my specific issue.

I am using an open source Text-To-Speech software from a third party in Java, and when I cancel and/or interrupt the text to speech message, child threads of the TTS thread are left in a waiting state. Using JConsole, I find messages for each waiting thread like:

Stack trace: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.park(Unknown Source) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source) java.util.concurrent.ArrayBlockingQueue.put(Unknown Source)

Is there a way I can interrupt or cancel a thread while safely cascading the stoppage of all other child threads?

I have experimented with an ExecutorService, daemon threads, and synchronous logic.

Please let me know if you have any suggestions. Thanks.

  • 2
    If you have a reference to that thread, you can `interrupt()` it directly. That doesn't necessarily mean it will actually stop what it's doing, though. The person who wrote it could ignore any interrupted state, thrown `InterruptedException`s, etc. – Radiodef Jul 18 '18 at 21:09
  • 3
    It's a bug in the Text-To-Speech software from a third party. They should release threads as they don't need them. Report a bug. Look for the close or destroy methods. Maybe there are some closure methods that are not called properly. – Pavel Molchanov Jul 18 '18 at 21:43
  • 1
    You can get a list of waiting threads as per this [post](https://stackoverflow.com/questions/7929351/java-list-of-waiting-threads). – prasad_ Jul 19 '18 at 05:51

0 Answers0