class TaskManager implements TaskListener<Task> {

    public static void waitForCompletion(final Task task)
            throws InterruptedException {
        if (task == null) {
            return;
        }
        TaskTerminationWaiter taskTerminationWaiter = new TaskTerminationWaiter(
                task);
        task.addTaskListener(taskTerminationWaiter);

        while (!task.getState().isFinished()) {
            synchronized (task) {
                task.wait(100);
            }
        }
        task.removeTaskListener(taskTerminationWaiter);

    }

    public  TaskManager();

}