{
ThreadPool pool;
MBeanServer server = getMBeanServer();
if(server != null)
{
ThreadPoolMBean poolMBean = (ThreadPoolMBean)MBeanServerInvocationHandler.
newProxyInstance(server, objName, ThreadPoolMBean.class, false);
pool = poolMBean.getInstance();
}
else
{
throw new RuntimeException("Can not register MBean ThreadPool as the ServerInvoker " +
"has not been registered with a MBeanServer.");