0

我正在使用 Spring 框架。

我有一个@Component扩展线程。在这堂课中,我使用 JNI 做一些事情。(从现在起我将其称为“A”)

此外,我有 2 个带@Scheduled注释的类。(从现在开始,我将它们称为“B”和“C”)

当我运行这个程序时会出现问题。如果“A”有效,则忽略其他。相反的情况也有效('B' 和 'C' 有效,而 'A' 无效)但事情永远不会一起工作。

我是这样编程的。

初始化 bean。下面是 root-context.xml 的一部分。

<!-- this works automatically when was is loaded -->
<!-- And I put @Component in that class -->
<bean name="initializer" class="org.owls.init.Starter" init-method="start"/>

预定 bean #1

@Component
class Schedule1 {
@Scheduled(cron="*/30 * * * * *")
public void doA(){
System.out.println("doA...");
}
}

调度 bean #2 与调度 bean #1 相同,除了 cron 表达式。(其表达式为cron="0 * * * * *".)

如何设置 bean 优先级或强制执行计划任务?

4

0 回答 0