我这种情况在Java中:Java的最佳方法(线程,和的DBus的HttpRequest)
在内部模块调用一 通过的DBus从一 这个大模Z通讯接收消息的大模Z一个外部服务器E(用于Dbus收到的每条消息)。
通过DBus架构,每当它完成一个请求时,在Z模块中就会创建一个新的线程来处理它。
什么是与E沟通的最佳方法?
a) Make a class with a method SendToExternalServer(). this method will be called every time that have a new DBus message.
i) The method has only one HttpUrlConnection.
ii) The method create a differente HttpUrlConnection instance every time is called.
b) Same situation on a) but now the method SendToExternalServer() is static
i) (same situations)
ii) (same situations)
c) Same situation on a) but the class extends the interface Runnable
i) (same situation)
ii) (same situation)
d) OTHER ?
在此先感谢 若昂
我不会为每个进入的事件创建一个新线程,而是使用一个使用线程池的事件分派器(如user949300所建议的执行程序)。 – 2012-04-18 16:45:29