【发布时间】:2013-01-09 21:48:04
【问题描述】:
BundleActivator 运行后台线程,而该后台线程出现不可恢复的错误怎么办?
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 框架线程已死并且捆绑包已有效停止且未运行?
【问题讨论】:
标签: java multithreading osgi