Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.Iterator;

import java.util.Map;

import java.util.concurrent.ExecutionException;

import java.util.concurrent.Future;

public class Main {
    public static void checkFutures(Map<? extends Object, Future<Void>> futures, int maxSize)
            throws InterruptedException, ExecutionException {
        while (futures.size() > maxSize) {
            for (Iterator<? extends Object> i = futures.keySet().iterator(); i.hasNext();) {
                Object key = i.next();
                futures.get(key).get();
                i.remove();
            }
        }
    }
}