さまざまなホストへの一連の JMX 接続を作成する必要があります。これらの接続を並行して作成しようとしています。このパフォーマンスでは、今でははるかに優れています。
「ホストとポート」エントリのコレクションを渡すメソッドがあります。エントリごとに 1 つの接続が作成されます。
現在、複数のスレッドへの接続を作成するこのタスクを提出しています。しかし、スレッドによって作成された接続オブジェクトを取得して保存する方法がわかりません。
コードは次のようになります。
ConnectionFactory.createConnections(collection of hostportEntries)
class ConnectionFactory{
public static CollectionOfConnections createConnections(ListOfHostPorts)
{
ExecutorService exec = Executors.newFixedThreadPool(4);
for(iterate over hostportEntries)
{
Future<Connection> future1 = exec.submit(new connCreator(HostPortEntry));
//Now here, connCreator is implementing Callable Interface and creating connection. and returning it. I'm taking reference of that Returned connection.
//But how will I take Multiple Connection objects returned by Multiple threads. I tried to create Future[] but OPTION like that doesn't seem to be there
// Can anybody help here?????
}
//if I succeed in getting the objects return then I'll store in one more collection and return those for further use of those connections.
}