6.5. Threading

A bundle or service can create and start any number of threads, and the duration of their execution depends on the operations defined in each thread's run method. Threads are especially useful because many callbacks from the framework are required to return promptly. For example, if you are to perform some long-running operation in the bundle activator's start method, you should spawn a thread to carry it out.

However, we also know that both the bundle and the service have life spans: For a bundle it is from when it is started to the time it is stopped; for a service it lasts from when the service is registered until it is unregistered. Consequently, it is important to program threads to cooperate with the life cycle of the bundle ...

Get Programming Open Service Gateways with Java Embedded Server™ Technology now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.