session.synchronize(Collections.singletonList(Session.JOB_IDS_SESSION_ALL),
Session.TIMEOUT_WAIT_FOREVER, true);
System.out.println("All jobs have finished.");
session.exit();
} catch (DrmaaException e) {
System.out.println("Error: " + e.getMessage());
}
}
}