spring cloud gateway openfeign 联合使用产生死锁问题,应用启动的时候阻塞卡住。
spring.cloud 版本如下
org.springframework.cloud spring-cloud-dependencies 2020.0.4 pom import
org.springframework.cloud spring-cloud-starter-gateway
org.springframework.cloud spring-cloud-starter-openfeign
java启动代码
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframewo服务器托管rk.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}
##追溯源码发现 boundedElastic-1线程阻塞在getSingleton方法synchronized (this.singletonObjects)锁上
那这时候主线程是否启动应用完成了呢?答案是没有,主线程也在实例化单例bean路上。追溯源码。主线程也在getSingleton方法synchronized (this.singletonObjects)锁上获取bean,boundedElastic-1线程正是主线程发起的,主线程在这里等待返回。boundedElastic-1线程在等待synchronized (this.singletonObjects)锁释放,主线程在getSingleton方法等待boundedElastic-1线程返回结果, 由此死锁产生了。应用启动阻塞卡住了。
##boundedElastic-1线程产生过程,贴几个重要方法
spring event 事件onApplicationEvent(ApplicationEvent event)
routeLocator.ifAvailable(locator -> locator.getRoutes().blockLast());blockLast方法是阻塞的。导致此bug主要原因。
##线程名字服务器托管
##工厂生产线程
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
朴素贝叶斯的定义: 朴素贝叶斯是一种基于贝叶斯定理与特征条件独立假设的分类方法。 朴素贝叶斯算法的核心思想是利用贝叶斯定理来进行概率推断,并在此基础上进行分类决策。它假设各个特征之间是相互独立的,尽管这个假设在实际应用中往往不成立,但这种简化通常能够带来计算上…