我的预定线程池--->
private static ScheduledExecutorService pendingCheckScheduler = Executors.newScheduledThreadPool(1);
线程 1--->
private ScheduledFuture<?> pendingTranStatusCheckHandle=pendingCheckScheduler.scheduleAtFixedRate(new PendingTranStatusCheck(),0,checkForPendingTrans,TimeUnit.SECONDS );
线程2--->
private ScheduledFuture<?> forcibleBatchCloseHandle=pendingCheckScheduler.schedule(new ForcibleBatchClose(), waitForPendingTrans, TimeUnit.MINUTES);
Thread 1
每 10 秒执行一次。Thread 2
应该在 30 分钟后开始。
Thread 1
行为与预期一样Thread2
,预计在 30 分钟后开始,在 1 小时后开始。
延迟thread1
是否导致了这个问题?如果是这样,thread2
考虑到我们在线程池中只有一个线程,当线程 1 完成时应该给予优先级。为什么Thread2
在 1 小时后启动时间过长?
我一无所知,期待一些指示。请帮助我。