{
System.out.println("Testing JMX Remoting Concurrency ...");
MBeanServer server = MBeanServerFactory.createMBeanServer();
// create a local connector
SocketConnector connector=new SocketConnector();
server.registerMBean(connector,new ObjectName("jmx.remoting:type=Connector,transport=socket"));
connector.start();
// create a remote connector looped-back to ourself
MBeanServerConnection conn=new MBeanServerConnection("socket",JMXUtil.getServerId(server),InstanceID.getID(server),InetAddress.getLocalHost(),connector.getTransportProperties());
MBeanServer remoteserver=ConnectorFactory.createConnector(conn);
Thread threads[]=new Thread[THREADS];
long start = System.currentTimeMillis();
for (int c=0;c<THREADS;c++)
{
threads[c]=new TestThread(remoteserver,ITERATIONS);
threads[c].start();
}
for (int c=0;c<THREADS;c++)
{
threads[c].join();
}
System.out.println(THREADS+" threads over "+ITERATIONS+" iterations took: "+(System.currentTimeMillis()-start)+" ms");
ConnectorFactory.destroyConnector(JMXUtil.getServerId(remoteserver));
server.unregisterMBean(new ObjectName("jmx.remoting:type=Connector,transport=socket"));
connector.stop();
connector.destroy();
connector = null;
server = null;
}