Dear all

My bundles need to use diverse threads to do their work (Timers, Workers, Events). And they need to clean them up on stop().

I have found this article (http://www.drdobbs.com/jvm/multithreading-java-osgi/191601642) which addresses the problem by using a Thread management class in each bundle, which keeps track of all threads and knows how to stop them when the bundle is stopping. It's a nice approach, but it's from 2006 and doesn't use Executors etc.

Also, my threads will work accross bundles - simplest example is the whiteboard pattern, which calls code in any registered listener, in any bundle.

Is the approach in this article the right way to go, to handle multithreading in OSGi? (ie. do you use it?) Are there other recommended approaches & best practices on how to manage (start, stop, share) multiple threads in OSGi? To avoid most of the synchronization, I will favor having only 1 main worker thread, where each client can submit tasks to perform (ExecutorService with a single thread). Is there a recommended OSGi approach for sharing this resource?

Thanks
  Philipp





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to