Java Code Examples for java.util.concurrent.RunnableScheduledFuture#isDone()

The following examples show how to use java.util.concurrent.RunnableScheduledFuture#isDone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrackingScheduledExecutor.java    From quarks with Apache License 2.0 6 votes vote down vote up
/**
 * Determines whether there are tasks which have started and not completed.
 * 
 * As a side effect, this method removes all tasks which are done but are
 * still in the tracking list.
 * 
 * @return {@code true} is active tasks exist.
 */
public boolean hasActiveTasks() {
    boolean doesHaveTasks = false; 
    synchronized (asyncTasks) {
        if (asyncTasks.isEmpty())
            return false;
        
        Iterator<RunnableScheduledFuture<?>> i = asyncTasks.iterator();
        while (i.hasNext()) {
            RunnableScheduledFuture<?> task = i.next();
            if (task.isDone())
                 i.remove();
            else
                doesHaveTasks = true;
        }
    }
    return doesHaveTasks;
}
 
Example 2
Source File: SchedulersTest.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
boolean isAllTasksCancelledOrDone() {
	for(RunnableScheduledFuture<?> task: tasks) {
		if (!task.isCancelled() && !task.isDone()) {
			return false;
		}
	}
	return true;
}