Class ThreadlessExecutor

java.lang.Object
java.util.concurrent.AbstractExecutorService
org.apache.dubbo.common.threadpool.ThreadlessExecutor
All Implemented Interfaces:
AutoCloseable, Executor, ExecutorService

public class ThreadlessExecutor extends AbstractExecutorService
The most important difference between this Executor and other normal Executor is that this one doesn't manage any thread.

Tasks submitted to this executor through execute(Runnable) will not get scheduled to a specific thread, though normal executors always do the schedule. Those tasks are stored in a blocking queue and will only be executed when a thread calls

invalid reference
#waitAndDrain()
, the thread executing the task is exactly the same as the one calling waitAndDrain.
  • Constructor Details

    • ThreadlessExecutor

      public ThreadlessExecutor()
  • Method Details

    • waitAndDrain

      public void waitAndDrain(long deadline) throws InterruptedException
      Waits until there is a task, executes the task and all queued tasks (if there're any). The task is either a normal response or a timeout response.
      Throws:
      InterruptedException
    • execute

      public void execute(Runnable runnable)
      If the calling thread is still waiting for a callback task, add the task into the blocking queue to wait for schedule. Otherwise, submit to shared callback executor directly.
      Parameters:
      runnable -
    • shutdown

      public void shutdown()
      The following methods are still not supported
    • shutdownNow

      public List<Runnable> shutdownNow()
    • isShutdown

      public boolean isShutdown()
    • isTerminated

      public boolean isTerminated()
    • awaitTermination

      public boolean awaitTermination(long timeout, TimeUnit unit)