0
在webapp中我想爲長進程運行異步線程並讓客戶端知道進程狀態。 爲此,我想使用這個抽象類:Spring和線程:找不到當前線程的會話
public abstract class ThreadProvider implements Runnable{
protected Thread thread;
public boolean create() throws SystemException{
if(thread!=null && thread.isAlive()) throw new SystemException("Il processo è già in esecuzione");
thread = new Thread(this);
thread.start();
return true;
}
}
這是我IMPL:
@Service @Transactional
public class ChiusuraProvider extends ThreadProvider {
private static Logger gdf = Logger.getLogger("gdf");
private static Logger log = Logger.getLogger(ChiusuraProvider.class);
protected Dao dao;
protected CinetelProvider cinetelProvider;
@Override
public void run() {...}
}
一切正常:線程啓動,似乎是自動裝配工作......然而Hibernat沒有找到任何會話(也許因爲我改變線程)...如何解決這個問題?
感謝