Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (C) 2008 The Guava Authors
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.common.util.concurrent;
A java.util.concurrent.FutureTask that also implements the ListenableFuture interface. Unlike FutureTask, ListenableFutureTask does not provide an overrideable done() method. For similar functionality, call addListener(java.lang.Runnable,java.util.concurrent.Executor).

Author(s):
Sven Mawson
Since:
1.0
public final class ListenableFutureTask<V> extends FutureTask<V>
    implements ListenableFuture<V> {
  // The execution list to hold our listeners.
  private final ExecutionList executionList = new ExecutionList();

  
Creates a ListenableFutureTask that will upon running, execute the given Callable.

Parameters:
callable the callable task
Since:
10.0
  public static <V> ListenableFutureTask<V> create(Callable<V> callable) {
    return new ListenableFutureTask<V>(callable);
  }

  
Creates a ListenableFutureTask that will upon running, execute the given Runnable, and arrange that get will return the given result on successful completion.

Parameters:
runnable the runnable task
result the result to return on successful completion. If you don't need a particular result, consider using constructions of the form: ListenableFuture<?> f = ListenableFutureTask.create(runnable, null)
Since:
10.0
  public static <V> ListenableFutureTask<V> create(
      Runnable runnable, @Nullable V result) {
    return new ListenableFutureTask<V>(runnableresult);
  }
  private ListenableFutureTask(Callable<V> callable) {
    super(callable);
  }
  private ListenableFutureTask(Runnable runnable, @Nullable V result) {
    super(runnableresult);
  }
  public void addListener(Runnable listenerExecutor exec) {
    .add(listenerexec);
  }

  
Internal implementation detail used to invoke the listeners.
  protected void done() {
  }
New to GrepCode? Check out our FAQ X