如何 运行 以预定的速度执行任务而不等待之前的任务?

How to run tasks at a scheduled rate that DON'T wait for the task before it?

目前,我有一些代码需要每(例如)33 毫秒 运行。但是,我调用的操作需要大约 270 毫秒。有没有一种方法可以安排我的任务,以便他们 运行 而不管他们面前的任务是什么?

我已经尝试实现一个 ScheduledExecutorService 变量并 运行 在 "ScheduledFixedRate" 处执行任务,但目前正在等待它之前的任务。

Runnable imageCapture = new Runnable() {

        public void run() {
            // code that takes approximately 270ms
        }
    };

executor = Executors.newScheduledThreadPool(4);
executor.scheduleAtFixedRate(imageCapture, 0, 33, TimeUnit.MILLISECONDS);

将任务一分为二:一个进行实际计算,另一个定期执行并启动第一个:

executor = Executors.newScheduledThreadPool(4);

Runnable imageCapture = new Runnable() {

    public void run() {
        // code that takes approximately 270ms
    }
};

Runnable launcher = new Runnable() {

    public void run() {
        executor.execute(imageCapture);
    }
};

executor.scheduleAtFixedRate(launcher, 0, 33, TimeUnit.MILLISECONDS);