Hi David, The component that you’re writing needs to be an “immediate” component, i.e. one that is not lazily created and released. This will mean that the component is eagerly activated, and only destroyed if/when dependencies become unavailable.
Some further thoughts: If you want to delay the thread creation until it is needed then that will need some more complex lifecycle handling as events are delivered. You could also time the thread out if nothing is in the queue for a period of time. What you’re describing sounds a lot like a ThreadPoolExecutor with a maximum size of one, so you could probably use that instead of a private blocking queue. I hope this helps, Tim > On 6 Oct 2016, at 14:09, David Daniel <david.daniel.1...@gmail.com> wrote: > > I have a service and it has a private blocking queue variable > > On activate it registers an eventhandler that writes to the queue on an > event. It also starts a thread that watches the blocking queue. > > My problem is that it is getting destroyed because nothing else depends on > the service. Is there a way to keep the service alive so the eventhandler is > not garbage collected > > Thanks for any help, > David > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev