ThreadPoolExecutor使用的时候指定线程前缀,便于问题排查 方法一: ThreadFactory threadFactory = new CustomizableThreadFactory("sjzgThread-"); ThreadPoolExecutor threadPoolZg = new ThreadPoolExecutor(6, 8, 10, TimeUnit.SECONDS, new LinkedBlockingQueue(Integer.MAX_VALUE),threadFactory);
方法二:
1、线程配置类 import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import java.util.concurrent.Executor; import java.util.concurrent.ThreadPoolExecutor; /** * 线程配置信息 **/ @Configuration @EnableAsync public class ThreadPoolConfig { @Bean("sjzgThreadPool") public Executor sjzgThreadPool() { ThreadPool服务器托管网TaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setQueueCapacity(Integer.MAX_VALUE); executor.setCorePoolSize(6); executor.setMaxPoolSize(8); executor.setKeepAliveSeconds(60); executor.setThreadNamePrefix("sjzgThread-"); // 线程池拒绝策略;AbortPolicy:丢弃并抛出异常;DiscardPolicy:丢弃但不抛异常;DiscardOldest服务器托管网Policy:丢弃最老的,把新的加进去;CallerRunsPolicy:主线程运行 executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); executor.initialize(); return executor; } }
2、使用
@Autowired private Executor sjzgThreadPool;
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
当前参与交付的语音识别产品服务,算法模块基于经典的Kaldi,算法中的一部分运行在GPU之上。 算法团队采用的是声学模型+语言模型的1-pass方案。这个方案的特点在于,语言模型数据文件(HCLG文件)的大小,和训练语料的丰富程度正相关,即语言文本的语料越多,…