Java Thread Executor isRegularlyDone(Future future)

Here you can find the source of isRegularlyDone(Future future)

Description

Checks if the specified Future terminated regularly, e.g.

License

Open Source License

Parameter

Parameter Description
future the Future to test for regularly completion.

Return

false if and only if calling throws an exception.

Declaration

static boolean isRegularlyDone(Future<?> future) 

Method Source Code

//package com.java2s;
/*//from   ww  w.  j a v a2  s .  c  o  m
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This file is part of SequentialExecutorService.
 *
 * SequentialExecutorService contains non-parallel implementations
 * for Java's ExecutorService and ScheduledExecutorService.
 * Copyright (C) 2015 Matthias Johannes Reimchen
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

public class Main {
    /**
     * Checks if the specified {@link Future} terminated regularly, e.g.
     * without throwing an Exception.
     *
     * @param future the Future to test for regularly completion.
     * @return false if and only if calling {@link Future#get()} throws an
     *         exception.
     */
    static boolean isRegularlyDone(Future<?> future) {
        try {
            future.get();
        } catch (InterruptedException | ExecutionException e) {
            return false;
        }
        return true;
    }
}

Related

  1. getActiveHelperInstanceCount(String helperName)
  2. getChannelService()
  3. getConstantLookup()
  4. getThreadExecutor(int nThreads)
  5. isCorrectCollectionSizeTimeOut(Collection collection, int size, long timeout, TimeUnit unit)
  6. isShutdown(Executor executor)
  7. isShutDown(ExecutorService executorService)
  8. setTimeout(Long duration, Runnable csr)
  9. submitTask(Runnable command)