当 aBundleActivator
运行一个后台线程,并且该后台线程出现不可恢复的错误时,应该怎么办?
public class Activator implements BundleActivator
{
private Thread t;
@Override
public void start(BundleContext context) throws Exception
{
t = new Thread(new Runnable(){
@Override
public void run(){
while (!Thread.interrupted()){
// do something which may throw a runtime exception
}
}
});
t.start();
}
@Override void stop(BundleContext context) throws Exception
{
t.interrupt();
t.join();
}
}
通过这个示例,我如何通知 OSGi 框架线程已死并且捆绑包已有效停止且未运行?