Java - Threads, Swing, and ServerSocket

后端 未结 2 874
面向向阳花
面向向阳花 2021-01-14 22:10

I know I know, already a million questions and answers on this everywhere. Tons of really detailed articles on it, several types of examples. I\'ve spent the past few hours

2条回答
  •  青春惊慌失措
    2021-01-14 22:24

    You are reading from your Socket on the EDT. This means that you block it. Calling invokeLater only causes your Runnable to be executed on the EDT. You are piling two calls on the EDT, one of them being your socket.

    Consider moving your socket in a SwingWorker which returns progressively the values of your Socker to the GUI.

提交回复
热议问题