Application hangs when attempting to retrieve text from an inputstream

流过昼夜 提交于 2019-12-02 11:23:38

I did look at your code, and as I suspected, your problem has absolutely nothing to do with the code you've posted. Your GUI completely ignores Swing threading rules, and calls long-running tasks on the main Swing event thread known as the Event Dispatch Thread or EDT. Since this thread is responsible for all Swing drawing and user interaction, your GUI is prevented from doing this and becomes completely frozen.

Please read Concurrency in Swing for the details on this.

And next time, please post an sscce so we don't have to dive into a huge amount of your source code! The key to the SSCCE is to eliminate all code not essential to your problem at hand. This is not easy to do and will require a lot of work from you to create, so that it has enough code to run, but not too much as to drown us in code, but then you are asking volunteers to help you on their free time, so it's not asking too much.

Best of luck!

Without reading all your explanations and all code attachments I can assume that you are reading from or writing to stream into UI thread (e.g. call IO operation from Action or ActionListener directly and you are blocked on read/write.

Please examine your code. I believe you will find point where you call to in.read() or out.write(). Add print just before and just after the line. You will see that you never exit read or write.

This is because the other side does not perform opposite operation. So, you have to:

  1. decouple UI from IO. IO must be done in separate thread.
  2. check why other side blocks your flow.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!