English 中文(简体)
单独铺设的连接表
原标题:Listening for connections in a separate thread

这是java的送信项目的一部分。 由于客户使用直接连接聊天线,我希望挖掘客户在某些港口进行聆听,而其他人则为这一地址提供记名。 但是,当一个叫Socket.accept()站在另一个路面时,似乎所有透镜均已停用。 也就是说,在执行这一指挥之后没有发生。 这里是新版的法典。

java.awt.EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        while(true){
                            System.out.println("flag1");
                            Socket socket = listeningSocket.accept();
                            System.out.println("flag2");
                            new Chat(socket).setVisible(true);;
                            jTextArea1.append("successfully connected
");
                        }
                    } catch (NullPointerException e) {
                        System.out.println("i know");
                    }
                    catch (IOException e) {
                        e.printStackTrace();
                        jTextArea1.append("error in recieving connection
");
                    }
                }
            });

any ideas how to solve this?

最佳回答

when i call ServerSocket.accept() in another thread it appears that all threads have been suspended

如何接受? 只是打断目前的read。 你们是否在《维也纳条约法公约》中呼吁? e. 一种操作方法? 捐资在这些方法中开展任何网络业务,使用单独的线索。

问题回答

Socket.accept() DOES阻挡了CURRENT的透镜。 页: 1 但是,这只阻碍了CURRENT的透镜。

我怀疑你没有正确操作单独的线索(你再说你开端,不正确吗?)





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签