[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Concurrent deployments

bela@jboss.com do-not-reply at jboss.com
Fri Feb 22 10:06:47 EST 2008


"adrian at jboss.org" wrote : Couldn't you just implement this anyway in your services, 
  | using the 2PC create/start lifecycle?
  | 
  | 
  |   | private volatile Thread startupThread;
  |   | 
  |   | public void create() throws Exception
  |   | {
  |   |    startupThread = new Thread(new Runnable()
  |   |    {
  |   |        public void run()
  |   |        {
  |   |           // start channel here
  |   |        }
  |   |    });
  |   |    startupThread.start();
  |   | }
  |   | 
  |   | public void start() throws Exception
  |   | {
  |   |     startThread.join(); // wait for startup to complete before injecting ourselves onto others
  |   |     startThread = null;
  |   | }
  |   | 
  | 
  | Of course, we could do better (e.g. using thread pools and "optimizing" 
  | related work across threads based on dependencies) if this was a feature of the MC.

No, since create only creates the channel, but start() connects it (time consuming operation), we'd block the main thread for the same time with the join()  as if we deployed on the main thread directly.

We could create a separate threads and not join() it, but that might have unintended consequences, such as channels not being ready when JBossCache (which has a dep on a channel) starts...

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131439#4131439

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131439



More information about the jboss-dev-forums mailing list