Tabnine Logo
Executors.callable
Code IndexAdd Tabnine to your IDE (free)

How to use
callable
method
in
java.util.concurrent.Executors

Best Java code snippets using java.util.concurrent.Executors.callable (Showing top 20 results out of 1,224)

origin: google/guava

@Override
public ListenableScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
 Preconditions.checkNotNull(command, "command must not be null");
 Preconditions.checkNotNull(unit, "unit must not be null!");
 return schedule(java.util.concurrent.Executors.callable(command), delay, unit);
}
origin: robovm/robovm

/**
 * @throws RejectedExecutionException {@inheritDoc}
 * @throws NullPointerException       {@inheritDoc}
 */
public <T> Future<T> submit(Runnable task, T result) {
  return schedule(Executors.callable(task, result), 0, NANOSECONDS);
}
origin: google/guava

/**
 * Wraps a {@code Runnable} for submission to the underlying executor. The default implementation
 * delegates to {@link #wrapTask(Callable)}.
 */
protected Runnable wrapTask(Runnable command) {
 final Callable<Object> wrapped = wrapTask(Executors.callable(command, null));
 return new Runnable() {
  @Override
  public void run() {
   try {
    wrapped.call();
   } catch (Exception e) {
    throwIfUnchecked(e);
    throw new RuntimeException(e);
   }
  }
 };
}
origin: stackoverflow.com

 ExecutorService es = Executors.newFixedThreadPool(2);
List<Callable<Object>> todo = new ArrayList<Callable<Object>>(singleTable.size());

for (DataTable singleTable: uniquePhrases) { 
  todo.add(Executors.callable(new ComputeDTask(singleTable))); 
}

List<Future<Object>> answers = es.invokeAll(todo);
origin: google/guava

/**
 * Creates a {@code ListenableFutureTask} that will upon running, execute the given {@code
 * Runnable}, and arrange that {@code get} will return the given result on successful completion.
 *
 * @param runnable the runnable task
 * @param result the result to return on successful completion. If you don't need a particular
 *     result, consider using constructions of the form: {@code ListenableFuture<?> f =
 *     ListenableFutureTask.create(runnable, null)}
 */
static <V> TrustedListenableFutureTask<V> create(Runnable runnable, @Nullable V result) {
 return new TrustedListenableFutureTask<V>(Executors.callable(runnable, result));
}
origin: prestodb/presto

/**
 * Wraps a {@code Runnable} for submission to the underlying executor. The default implementation
 * delegates to {@link #wrapTask(Callable)}.
 */
protected Runnable wrapTask(Runnable command) {
 final Callable<Object> wrapped = wrapTask(Executors.callable(command, null));
 return new Runnable() {
  @Override
  public void run() {
   try {
    wrapped.call();
   } catch (Exception e) {
    throwIfUnchecked(e);
    throw new RuntimeException(e);
   }
  }
 };
}
origin: google/j2objc

/**
 * Wraps a {@code Runnable} for submission to the underlying executor. The default implementation
 * delegates to {@link #wrapTask(Callable)}.
 */
protected Runnable wrapTask(Runnable command) {
 final Callable<Object> wrapped = wrapTask(Executors.callable(command, null));
 return new Runnable() {
  @Override
  public void run() {
   try {
    wrapped.call();
   } catch (Exception e) {
    throwIfUnchecked(e);
    throw new RuntimeException(e);
   }
  }
 };
}
origin: apache/incubator-pinot

@Override
public <T> Future<T> submit(Runnable task, T result) {
 return submit(Executors.callable(task, result));
}
origin: apache/incubator-pinot

@Override
public Future<?> submit(Runnable task) {
 return submit(Executors.callable(task));
}
origin: apache/flume

/**
 * <p>
 * A convenience method for transactions that don't require a return
 * value.  Simply wraps the <code>transactor</code> using {@link
 * Executors#callable} and passes that to {@link
 * #transact(Channel,Callable)}.
 * </p>
 * @see #transact(Channel,Callable)
 * @see Executors#callable(Runnable)
 */
public static void transact(Channel channel, Runnable transactor)
  throws ChannelException {
 transact(channel, Executors.callable(transactor));
}
origin: prestodb/presto

/**
 * Creates a {@code ListenableFutureTask} that will upon running, execute the given {@code
 * Runnable}, and arrange that {@code get} will return the given result on successful completion.
 *
 * @param runnable the runnable task
 * @param result the result to return on successful completion. If you don't need a particular
 *     result, consider using constructions of the form: {@code ListenableFuture<?> f =
 *     ListenableFutureTask.create(runnable, null)}
 */
static <V> TrustedListenableFutureTask<V> create(Runnable runnable, @NullableDecl V result) {
 return new TrustedListenableFutureTask<V>(Executors.callable(runnable, result));
}
origin: google/j2objc

/**
 * Creates a {@code ListenableFutureTask} that will upon running, execute the given {@code
 * Runnable}, and arrange that {@code get} will return the given result on successful completion.
 *
 * @param runnable the runnable task
 * @param result the result to return on successful completion. If you don't need a particular
 *     result, consider using constructions of the form: {@code ListenableFuture<?> f =
 *     ListenableFutureTask.create(runnable, null)}
 */
static <V> TrustedListenableFutureTask<V> create(Runnable runnable, @NullableDecl V result) {
 return new TrustedListenableFutureTask<V>(Executors.callable(runnable, result));
}
origin: netty/netty

@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
  ObjectUtil.checkNotNull(command, "command");
  ObjectUtil.checkNotNull(unit, "unit");
  if (initialDelay < 0) {
    throw new IllegalArgumentException(
        String.format("initialDelay: %d (expected: >= 0)", initialDelay));
  }
  if (period <= 0) {
    throw new IllegalArgumentException(
        String.format("period: %d (expected: > 0)", period));
  }
  validateScheduled0(initialDelay, unit);
  validateScheduled0(period, unit);
  return schedule(new ScheduledFutureTask<Void>(
      this, Executors.<Void>callable(command, null),
      ScheduledFutureTask.deadlineNanos(unit.toNanos(initialDelay)), unit.toNanos(period)));
}
origin: netty/netty

@Override
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
  ObjectUtil.checkNotNull(command, "command");
  ObjectUtil.checkNotNull(unit, "unit");
  if (initialDelay < 0) {
    throw new IllegalArgumentException(
        String.format("initialDelay: %d (expected: >= 0)", initialDelay));
  }
  if (delay <= 0) {
    throw new IllegalArgumentException(
        String.format("delay: %d (expected: > 0)", delay));
  }
  validateScheduled0(initialDelay, unit);
  validateScheduled0(delay, unit);
  return schedule(new ScheduledFutureTask<Void>(
      this, Executors.<Void>callable(command, null),
      ScheduledFutureTask.deadlineNanos(unit.toNanos(initialDelay)), -unit.toNanos(delay)));
}
origin: wildfly/wildfly

/**
 * Creates a {@code ListenableFutureTask} that will upon running, execute the given {@code
 * Runnable}, and arrange that {@code get} will return the given result on successful completion.
 *
 * @param runnable the runnable task
 * @param result the result to return on successful completion. If you don't need a particular
 *     result, consider using constructions of the form: {@code ListenableFuture<?> f =
 *     ListenableFutureTask.create(runnable, null)}
 */
static <V> TrustedListenableFutureTask<V> create(Runnable runnable, @NullableDecl V result) {
 return new TrustedListenableFutureTask<V>(Executors.callable(runnable, result));
}
origin: redisson/redisson

@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
  ObjectUtil.checkNotNull(command, "command");
  ObjectUtil.checkNotNull(unit, "unit");
  if (initialDelay < 0) {
    throw new IllegalArgumentException(
        String.format("initialDelay: %d (expected: >= 0)", initialDelay));
  }
  if (period <= 0) {
    throw new IllegalArgumentException(
        String.format("period: %d (expected: > 0)", period));
  }
  validateScheduled0(initialDelay, unit);
  validateScheduled0(period, unit);
  return schedule(new ScheduledFutureTask<Void>(
      this, Executors.<Void>callable(command, null),
      ScheduledFutureTask.deadlineNanos(unit.toNanos(initialDelay)), unit.toNanos(period)));
}
origin: redisson/redisson

@Override
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
  ObjectUtil.checkNotNull(command, "command");
  ObjectUtil.checkNotNull(unit, "unit");
  if (initialDelay < 0) {
    throw new IllegalArgumentException(
        String.format("initialDelay: %d (expected: >= 0)", initialDelay));
  }
  if (delay <= 0) {
    throw new IllegalArgumentException(
        String.format("delay: %d (expected: > 0)", delay));
  }
  validateScheduled0(initialDelay, unit);
  validateScheduled0(delay, unit);
  return schedule(new ScheduledFutureTask<Void>(
      this, Executors.<Void>callable(command, null),
      ScheduledFutureTask.deadlineNanos(unit.toNanos(initialDelay)), -unit.toNanos(delay)));
}
origin: ben-manes/caffeine

/**
 * Executes a task, on N threads, all starting at the same time.
 *
 * @param nThreads the number of threads to execute
 * @param task the task to execute in each thread
 * @return the execution time for all threads to complete, in nanoseconds
 */
public static long timeTasks(int nThreads, Runnable task) {
 return timeTasks(nThreads, Executors.callable(task)).executionTime();
}
origin: google/guava

allTasks.add(cancelRunnable);
allTasks.add(setFutureCompleteSucessFullyRunnable);
allTasks.add(Executors.callable(collectResultsRunnable));
assertEquals(allTasks.size() + 1, barrier.getParties()); // sanity check
for (int i = 0; i < 1000; i++) {
origin: google/guava

public void testSchedule() {
 MockExecutor mock = new MockExecutor();
 TestExecutor testExecutor = new TestExecutor(mock);
 @SuppressWarnings("unused") // go/futurereturn-lsc
 Future<?> possiblyIgnoredError = testExecutor.schedule(DO_NOTHING, 10, TimeUnit.MINUTES);
 mock.assertLastMethodCalled("scheduleRunnable", 10, TimeUnit.MINUTES);
 @SuppressWarnings("unused") // go/futurereturn-lsc
 Future<?> possiblyIgnoredError1 =
   testExecutor.schedule(Executors.callable(DO_NOTHING), 5, TimeUnit.SECONDS);
 mock.assertLastMethodCalled("scheduleCallable", 5, TimeUnit.SECONDS);
}
java.util.concurrentExecutorscallable

Javadoc

Returns a Callable object that, when called, runs the given task and returns null.

Popular methods of Executors

  • newFixedThreadPool
    Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue,
  • newSingleThreadExecutor
    Creates an Executor that uses a single worker thread operating off an unbounded queue, and uses the
  • newCachedThreadPool
    Creates a thread pool that creates new threads as needed, but will reuse previously constructed thre
  • newSingleThreadScheduledExecutor
    Creates a single-threaded executor that can schedule commands to run after a given delay, or to exec
  • newScheduledThreadPool
    Creates a thread pool that can schedule commands to run after a given delay, or to execute periodica
  • defaultThreadFactory
    Returns a default thread factory used to create new threads. This factory creates all new threads us
  • unconfigurableScheduledExecutorService
    Returns an object that delegates all defined ScheduledExecutorService methods to the given executor,
  • unconfigurableExecutorService
    Returns an object that delegates all defined ExecutorService methods to the given executor, but not
  • newWorkStealingPool
    Creates a thread pool that maintains enough threads to support the given parallelism level, and may
  • privilegedThreadFactory
    Legacy security code; do not use.
  • privilegedCallable
    Legacy security code; do not use.
  • privilegedCallableUsingCurrentClassLoader
    Legacy security code; do not use.
  • privilegedCallable,
  • privilegedCallableUsingCurrentClassLoader

Popular in Java

  • Making http post requests using okhttp
  • getExternalFilesDir (Context)
  • onRequestPermissionsResult (Fragment)
  • addToBackStack (FragmentTransaction)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JFrame (javax.swing)
  • JPanel (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now