EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
UiJob job = evt.getJob();
JobSnapshot snapshot = new JobSnapshot(job);
// If the job finishes quickly it can already be done when we reach this
// point --> the snapshot will never end if we start it, so we don't start it.
// XXX: Potential race condition here. The if-else statement needs to be
// atomic with respect to the state of the UiJob
if (job.isRunning()) {
snapshot.started(job);
job.addProgressMonitor(snapshot);
} else {
snapshot.ended();
}
snapshots.addFirst(snapshot);
updateLayout();
}
});