Here you can find the source of getWithTimeout(final Future
Parameter | Description |
---|---|
future | future |
T | type |
Parameter | Description |
---|---|
Exception | exception |
static <T> T getWithTimeout(final Future<T> future) throws Exception
//package com.java2s; /*/* w w w.ja va2s.co m*/ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; public class Main { private static final long TIMEOUT = 3; /** * Calls {@link Future#get(long, TimeUnit)} with {@link TestUtils#TIMEOUT} in seconds. * * @param future future * @param <T> type * @return future result * @throws Exception exception */ static <T> T getWithTimeout(final Future<T> future) throws Exception { return future.get(TIMEOUT, TimeUnit.SECONDS); } }