1,spring 启动时,限制bean的加载顺序:@DependsOnnode
该注解用于声明当前bean依赖于另一个bean。所依赖的bean会被容器确保在当前bean实例化以前被实例化。spring
例如:线程
@DependsOn({"nodesServiceImpl"})
bean名称,默认为类名称首字母小写。io
2,主要是运用类:function
CountDownLatch latch;
CountDownLatch可以使一个线程在等待另一些线程完成各自工做以后,再继续执行。使用一个计数器进行实现。计数器初始值为线程的数量。当每个线程完成本身任务后,计数器的值就会减一。当计数器的值为0时,表示全部的线程都已经完成了任务,而后在CountDownLatch上等待的线程就能够恢复执行任务。容器
executorService = Executors.newFixedThreadPool(size); latch = new CountDownLatch(size);
executorService.execute(() -> function());
在function中执行完业务要调用vi
latch.countDown();
OK!co