Class OrderedExecutor

    • Constructor Detail

      • OrderedExecutor

        public OrderedExecutor​(int numThreads,
                               ExecutorService delegate)
    • Method Detail

      • execute

        public void execute​(Integer lockId,
                            Runnable command)
        Execute the given command in the future. If another command with same lockId is waiting in the queue or running, this method will block until that command finish. Therefore different commands with same hash will be executed in order of calling this method. If multiple caller are waiting for a command to finish, there are no guarantee that the earliest call will win.
        lockId - of the command, if null then a random hash will be generated
        command - the runnable task
        RejectedExecutionException - if this task cannot be accepted for execution
      • shutdownAndAwaitTermination

        public void shutdownAndAwaitTermination()