All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.util.concurrent.FutureTask Maven / Gradle / Ivy

Go to download

JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.

The newest version!
package java.util.concurrent;

public class FutureTask implements RunnableFuture {
	private V result;

	public FutureTask(Callable callable) {
		try {
			result = callable.call();
		} catch (Exception e) {
			e.printStackTrace();
			result = null;
		}
	}

	public FutureTask(Runnable runnable, V result) {
		runnable.run();
		this.result = result;
	}

	@Override
	public void run() {
		// @TODO: Should call exeuction here instead of the constructor?
	}

	@Override
	public boolean cancel(boolean mayInterruptIfRunning) {
		return false;
	}

	@Override
	public boolean isCancelled() {
		return false;
	}

	@Override
	public boolean isDone() {
		return true;
	}

	@Override
	public V get() throws InterruptedException, ExecutionException {
		return result;
	}

	@Override
	public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
		return get();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy