Server based SwingWorker does not Stop

巧了我就是萌 提交于 2019-11-29 12:30:24

Your ServerSocket is what's causing the loop to not terminate. Even though 'ecoute' is false, server.accept() will block until one of the following two conditions is met:

  1. A connection is made to the ServerSocket
  2. The ServerSocket is closed.

You need to do one of these two things so that the call to server.accept() will stop blocking. Mind you - if you choose to close the ServerSocket, an IOException will get thrown. It would probably be better to wrap the call to server.accept() in the try block, instead of wrapping the entire doInBackground() function.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!