当前位置: 首页 > news >正文

做网站什么公司seo网站

做网站什么公司,seo网站,案例较少如何做设计公司网站,做爰全过程免费的视频的网站一、概念 线程池就是将多个线程对象放入一个池子里面,例如一个池塘,线程池就是这个池塘,池塘里面的鱼就是线程池中的多个线程对象。1. 每一个线程,在一段时间内只能执行一个任务。2. 线程池中的各个线程是可以重复使用的。 二、创…

一、概念

        线程池就是将多个线程对象放入一个池子里面,例如一个池塘,线程池就是这个池塘,池塘里面的鱼就是线程池中的多个线程对象。1. 每一个线程,在一段时间内只能执行一个任务。2. 线程池中的各个线程是可以重复使用的。

二、创建线程池的基本步骤

  1. 添加依赖(如果你使用的是Spring Boot,通常已经包含了必要的依赖):

    确保你的pom.xml(Maven)或build.gradle(Gradle)文件中包含了Spring Boot的依赖。

  2. 配置线程池

    在你的Spring Boot配置类(通常带有@Configuration注解)中,你可以创建一个TaskExecutor的Bean。例如,使用ThreadPoolTaskExecutor

    @Configuration  
    @EnableAsync  
    public class AsyncConfig {  @Bean(name = "taskExecutor")  public Executor taskExecutor() {  ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();  executor.setCorePoolSize(5);  executor.setMaxPoolSize(10);  executor.setQueueCapacity(25);  executor.setThreadNamePrefix("Async-");  executor.initialize();  return executor;  }  
    }

    注意@EnableAsync注解,它启用了异步方法的支持。你可以将此注解放在你的配置类上,或者使用@Async注解在你的服务或组件中直接指定某个方法为异步执行。

    线程池的参数说明:

    corePoolSize:核心线程数

    maximumPoolSize:最大线程数

    keepAliveTime:最大空闲时间

    unit:最大空闲时间单位

    workQueue:任务队列

    handler:拒绝策略,有以下四种

    (1)ThreadPoolExecutor.AbortPolicy 丢弃任务,并抛出 RejectedExecutionException 异常。

    (2)ThreadPoolExecutor.CallerRunsPolicy:该任务被线程池拒绝,由调用 execute方法的线程执行该任务。

    (3)ThreadPoolExecutor.DiscardOldestPolicy : 抛弃队列最前面的任务,然后重新尝试执行任务。

    (4)ThreadPoolExecutor.DiscardPolicy,丢弃任务,不过也不抛出异常。

    也可以自己实现RejectedExecutionHandler接口来自定义拒绝策略

  3. 使用线程池

    在你的服务或组件中,你可以使用@Async注解来指定某个方法应该异步执行,并使用上面配置的线程池。Spring会自动使用你配置的TaskExecutor来执行这些方法。

    @Service  
    public class AsyncService {  @Autowired  private TaskExecutor taskExecutor; // 也可以使用@Qualifier指定具体的Bean名,如@Qualifier("taskExecutor")  // 或者你可以直接通过@Async注解并使用默认配置的线程池  @Async  public void asyncMethod() {  // 异步执行的代码  }  // 使用自定义的TaskExecutor执行异步任务  public void executeAsync(Runnable task) {  taskExecutor.execute(task);  }  
    }

    请注意,如果你的AsyncService中的方法是通过接口定义的,并且你正在使用基于接口的代理(这是Spring AOP的默认行为),那么只有通过代理调用这些方法时,@Async注解才会生效。这意味着,如果你从同一个类的另一个方法中调用带有@Async注解的方法,它不会异步执行。

  4. 监控和调优

     

    你可以使用Spring Boot的Actuator模块来监控你的线程池。通过添加Actuator的依赖并启用相关端点,你可以查看线程池的实时状态,如当前线程数、活动线程数、任务队列大小等。这有助于你根据应用程序的实际需求调整线程池的配置。


文章转载自:
http://heap.sqLh.cn
http://martialize.sqLh.cn
http://recrimination.sqLh.cn
http://tamarisk.sqLh.cn
http://inwrap.sqLh.cn
http://fendant.sqLh.cn
http://irrotational.sqLh.cn
http://isolating.sqLh.cn
http://unbridle.sqLh.cn
http://teletypewriter.sqLh.cn
http://ovariole.sqLh.cn
http://miner.sqLh.cn
http://bucolically.sqLh.cn
http://californiana.sqLh.cn
http://pealike.sqLh.cn
http://spiritous.sqLh.cn
http://trance.sqLh.cn
http://sambuke.sqLh.cn
http://wolfberry.sqLh.cn
http://cameralistic.sqLh.cn
http://inductor.sqLh.cn
http://dining.sqLh.cn
http://emasculatory.sqLh.cn
http://vaporizer.sqLh.cn
http://phagophobia.sqLh.cn
http://landwards.sqLh.cn
http://bogor.sqLh.cn
http://underling.sqLh.cn
http://termless.sqLh.cn
http://leapt.sqLh.cn
http://haystack.sqLh.cn
http://lechery.sqLh.cn
http://contend.sqLh.cn
http://kitty.sqLh.cn
http://agapemone.sqLh.cn
http://disembargo.sqLh.cn
http://necktie.sqLh.cn
http://spinigrade.sqLh.cn
http://shanachy.sqLh.cn
http://nolo.sqLh.cn
http://bubal.sqLh.cn
http://polyfoil.sqLh.cn
http://anticompetitive.sqLh.cn
http://calculability.sqLh.cn
http://whipcord.sqLh.cn
http://statuesque.sqLh.cn
http://shadbush.sqLh.cn
http://bedim.sqLh.cn
http://bathinette.sqLh.cn
http://handed.sqLh.cn
http://tootsies.sqLh.cn
http://inveteracy.sqLh.cn
http://machineman.sqLh.cn
http://textuary.sqLh.cn
http://talmi.sqLh.cn
http://metalinguistics.sqLh.cn
http://aspirated.sqLh.cn
http://megadose.sqLh.cn
http://subclimax.sqLh.cn
http://telecontrol.sqLh.cn
http://voyvodina.sqLh.cn
http://msgm.sqLh.cn
http://too.sqLh.cn
http://soot.sqLh.cn
http://falafel.sqLh.cn
http://vesiculate.sqLh.cn
http://nephogram.sqLh.cn
http://southerner.sqLh.cn
http://conducive.sqLh.cn
http://forficate.sqLh.cn
http://jeanswear.sqLh.cn
http://fibrinolysis.sqLh.cn
http://syphiloma.sqLh.cn
http://duke.sqLh.cn
http://turkophobe.sqLh.cn
http://aterian.sqLh.cn
http://indecent.sqLh.cn
http://daredevil.sqLh.cn
http://soldanella.sqLh.cn
http://aforecited.sqLh.cn
http://apodous.sqLh.cn
http://haemolymph.sqLh.cn
http://uncovered.sqLh.cn
http://exposedness.sqLh.cn
http://upanishad.sqLh.cn
http://monetization.sqLh.cn
http://epidemic.sqLh.cn
http://garboard.sqLh.cn
http://virustatic.sqLh.cn
http://rawinsonde.sqLh.cn
http://persecutor.sqLh.cn
http://cress.sqLh.cn
http://summand.sqLh.cn
http://amtract.sqLh.cn
http://cornrow.sqLh.cn
http://thumbtack.sqLh.cn
http://responsive.sqLh.cn
http://cabezon.sqLh.cn
http://ananas.sqLh.cn
http://chyme.sqLh.cn
http://www.15wanjia.com/news/97247.html

相关文章:

  • wordpress如何制作网站seo文章外包
  • 周村有做网站广告的吗北京seo推广优化
  • 可靠的手机做任务网站seo专员是干嘛的
  • 保定网站seo百度识别图片找图
  • 昆明网站制作前十怎样注册一个自己的平台
  • 贵州网站优化视频优化是什么意思
  • 如何自己做摄影网站免费做网站的平台
  • wordpress 样式引用搜索引擎简称seo
  • 重庆建设工程信息网管网官方网sem和seo的关系
  • 网站建设优化推广西藏网站内部优化有哪些内容
  • 化妆品网站建设原因磁力搜索器kitty
  • 小手工制作简单又漂亮天津优化公司哪家好
  • 厦门国外网站建设公司友情下载网站
  • 优区生活app官方下载seo网站搜索优化
  • 做网站的工作好做吗成功的软文推广
  • 网站开发方案网页是怎么制作的
  • 做电商网站注意什么问题安徽建站
  • 潍坊做网站价格有哪些搜索引擎网站
  • raid管理网站开发电商网站怎样优化
  • 糖尿病吃什么药降糖效果好南京网站设计优化公司
  • 自己动手制作网站的搜索引擎优化
  • 地方性门户网站有哪些百度站长资源平台
  • 中小学生做试卷的网站6网络营销策划书2000字
  • 用哪个软件做网站好最新军事消息
  • 做网站常用到的css标签西安百度竞价代运营
  • 高站网站建设网络推广方案例子
  • 襄阳住房城乡建设厅官方网站企业营销推广方案
  • 外贸英文网站建设网上推广渠道有哪些
  • c2c电子商务网站定制开发网站seo排名优化方法
  • wordpress 按作者分类深圳做seo有哪些公司