1 Reply Latest reply on Sep 16, 2004 6:02 PM by Dimitris Andreadis

    JBoss and Multithreading

    javacoder Newbie

      Hello Community,

      I am having some problems. I am newbie for JBoss, but managed to create MBeans and deployed it. I have created the MBeans to control a Processing and Filtering (P&F) server, to start and stop. Once the P&F server is started it is transfering the data between itself and Data Acqusition Dispatcher (DAQ dispatcher).
      There is a protocol defined by DAQ disptacher for P&F server. For the command I am having problem is QUIT. When P&F server is stopping the DAQ dispatcher says QUIT and makes sure that socket connection is closed. When I am doing thru command line, things are working perfectly fine.
      But when I am invoking the Start and Stop command from the JBoss, the Start is starting the P&F server. But when I am invoking the Stop command it stops the data transfer between DAQ dispatcher and P&F server, but it is not stopping the P&F server. The reason, I have found out, but don't know how to solve it.
      What exactly is happening, the P&F server is multithreaded program, wo when the server starts the it spawns the threads. But when I stop the server data transfer is stopped but all the threads created by P&F server they are alive, thats why the Stop is not working and DAQ dispatcher is not showing the QUIT and socket closed message. Because JBoss is always running, when I goto the prompt from where I have started the JBoss, and hit CTRL 'C" all the threads are released because it stops the JBoss and then DAQ dispatcher says, QUIT and all socket closed.
      Please, let me know how can I enforce the JBoss to release the thread without stopping the JBoss.

      Thanks in advance,

        • 1. Re: JBoss and Multithreading
          Dimitris Andreadis Master

          JBoss has no control over the threads your MBean creates.

          A possible solution is to include a boolean flag with your MBean (e.g. isStopRequested) and set it when stop() is called. Your threads would have to periodically check this flag and exit if they find it set.

          An extention to that would be for the call to stop() to actually wait, until all thread have exited/joined, before returning.