我在Java中有这种情况:
在称为 I 的内部模块上。一个大模块 Z 通过 DBus 从 I 接收消息。这个大模块 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 ?
提前感谢若昂