while (iter.hasNext()) { final K key = iter.next(); final TimerTask task = checkMinIdle(keyedPool, key, minIdle, period); tasks.put(key, task);
/** * Periodically check the idle object count for each key in the <code>Collection</code> <code>keys</code> in the keyedPool. * At most one idle object will be added per period. * * @param keyedPool the keyedPool to check periodically. * @param keys a collection of keys to check the idle object count. * @param minIdle if the {@link KeyedObjectPool#getNumIdle(Object)} is less than this then add an idle object. * @param period the frequency to check the number of idle objects in a keyedPool, see * {@link Timer#schedule(TimerTask, long, long)}. * @return a {@link Map} of key and {@link TimerTask} pairs that will periodically check the pools idle object count. * @throws IllegalArgumentException when <code>keyedPool</code>, <code>keys</code>, or any of the values in the * collection is <code>null</code> or when <code>minIdle</code> is negative or when <code>period</code> isn't * valid for {@link Timer#schedule(TimerTask, long, long)}. * @see #checkMinIdle(KeyedObjectPool, Object, int, long) * @since Pool 1.3 */ public static Map checkMinIdle(final KeyedObjectPool keyedPool, final Collection keys, final int minIdle, final long period) throws IllegalArgumentException { if (keys == null) { throw new IllegalArgumentException("keys must not be null."); } final Map tasks = new HashMap(keys.size()); final Iterator iter = keys.iterator(); while (iter.hasNext()) { final Object key = iter.next(); final TimerTask task = checkMinIdle(keyedPool, key, minIdle, period); tasks.put(key, task); } return tasks; }
while (iter.hasNext()) { final K key = iter.next(); final TimerTask task = checkMinIdle(keyedPool, key, minIdle, period); tasks.put(key, task);
/** * Periodically check the idle object count for each key in the <code>Collection</code> <code>keys</code> in the keyedPool. * At most one idle object will be added per period. * * @param keyedPool the keyedPool to check periodically. * @param keys a collection of keys to check the idle object count. * @param minIdle if the {@link KeyedObjectPool#getNumIdle(Object)} is less than this then add an idle object. * @param period the frequency to check the number of idle objects in a keyedPool, see * {@link Timer#schedule(TimerTask, long, long)}. * @return a {@link Map} of key and {@link TimerTask} pairs that will periodically check the pools idle object count. * @throws IllegalArgumentException when <code>keyedPool</code>, <code>keys</code>, or any of the values in the * collection is <code>null</code> or when <code>minIdle</code> is negative or when <code>period</code> isn't * valid for {@link Timer#schedule(TimerTask, long, long)}. * @see #checkMinIdle(KeyedObjectPool, Object, int, long) * @since Pool 1.3 */ public static Map checkMinIdle(final KeyedObjectPool keyedPool, final Collection keys, final int minIdle, final long period) throws IllegalArgumentException { if (keys == null) { throw new IllegalArgumentException("keys must not be null."); } final Map tasks = new HashMap(keys.size()); final Iterator iter = keys.iterator(); while (iter.hasNext()) { final Object key = iter.next(); final TimerTask task = checkMinIdle(keyedPool, key, minIdle, period); tasks.put(key, task); } return tasks; }
while (iter.hasNext()) { final K key = iter.next(); final TimerTask task = checkMinIdle(keyedPool, key, minIdle, period); tasks.put(key, task);