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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access