내 응용 프로그램에는 두 개의 jtextpanes가 있으며 몇 가지 작업이 포함 된 executorservice instacne이 있습니다. executorervice 인스턴스의 모든 작업이 모든 jtextpanes의 FocusListener focusGained 메소드를 실행하기 전에 완료되었는지 확인하고 싶습니다. 또한 focusLost 메서드가 호출 될 때 executorservice에 몇 가지 작업을 추가합니다.executorervice가 모든 작업을 완료 할 때까지 EDT 차단
코드
top.addFocusListener(new FocusListener()
{
public void focusLost(FocusEvent e)
{
if (ecaViewControl.isInitialized())
{
stopRecording();
executor.execute(new Runnable()
{
public void run()
{
ecaViewControl.save(top);
}
});
executor.execute(new Runnable()
{
public void run()
{
ecaViewControl.closeDocument();
}
});
}
}
public void focusGained(FocusEvent e)
{
//Need to have completed all the task in executor service before EDT executes the code in here
});
}
그래서 모든 작업이 완료 될 때까지 UI를 차단 하시겠습니까? 그거 좋은 생각이야? – Tudor