In my application i have two jtextpanes and i have a executorservice instacne which contains few task. I want to assure that all the task in the executorservice instance are completed before executing the FocusListener focusGained method of any jtextpanes. Also i add some more task to the executorservice when focusLost method is called.
Code
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
});
}