2 Replies Latest reply on Jun 16, 2010 9:38 AM by gertv

    Fuse 4: Spawned thread within OSGI bundle wont die when stopped

    guest

      Hello, I'm a newbie to this stuff and I notice when I stop my osgi bundle, the threads within it seem to stay alive.  How can I stop the threads upon stopping the bundle?  Thanks.

        • 1. Re: Fuse 4: Spawned thread within OSGI bundle wont die when stopped
          ffang

          Hi,

           

          Don't know the details about your scenario, but you can specify a BundleActivator for your bundle, and in the stop method of BundleActivator, you can do some clean up work(like release some resources).

           

          Or you can have a watch dog bundle, which implements BundleListener interface, when the BundleEvent type is BundleEvent.STOP, you can get the stopped bundle from BundleEvent and do any cleanup work there.

           

          Freeman

          • 2. Re: Fuse 4: Spawned thread within OSGI bundle wont die when stopped
            gertv

            L.S.,

             

            Another option would be to use Blueprint or Spring DM to create the threads from a bean and use the init-method/destroy-method attributes to specify the methods to handle the lifecycle of your threads when the Blueprint context gets started.

             

            Regards,

             

            Gert Vanthienen