您现在的位置是:主页 > news > wordpress地址(url)站点地址(url)/百度seo详解

wordpress地址(url)站点地址(url)/百度seo详解

admin2025/6/20 12:13:35news

简介wordpress地址(url)站点地址(url),百度seo详解,抖音代运营保证金,毕业设计代做网站唯一注意点 main一启动就产生一个线程 计划任务可以直接用main线程 所有线程池核心设置为1个即可,否则会产生很多线程,浪费资源 JVM调优图 //每周某个特定时间执行 public class ScheduledDay {public static void main(String[] args) {//获取当前时间L…

wordpress地址(url)站点地址(url),百度seo详解,抖音代运营保证金,毕业设计代做网站唯一注意点 main一启动就产生一个线程 计划任务可以直接用main线程 所有线程池核心设置为1个即可,否则会产生很多线程,浪费资源 JVM调优图 //每周某个特定时间执行 public class ScheduledDay {public static void main(String[] args) {//获取当前时间L…

注意点

main一启动就产生一个线程

计划任务可以直接用main线程

所有线程池核心设置为1个即可,否则会产生很多线程,浪费资源

JVM调优图

在这里插入图片描述

//每周某个特定时间执行
public class ScheduledDay {public static void main(String[] args) {//获取当前时间LocalDateTime now = LocalDateTime.now();//获取目标时间(周一,03:59)LocalDateTime target = now.with(DayOfWeek.MONDAY).withHour(3).withMinute(59).withSecond(0).withNano(0);//如果当前时间>本周目标时间,排除本周,找下周if (now.compareTo(target) > 0) {target = target.plusWeeks(1);}//差值long initialDelay = Duration.between(now, target).toMillis();//间隔时间——每周long period = 1000 * 60 * 60 * 24 * 7;ScheduledExecutorService pool = scheduledExecutorService();pool.scheduleAtFixedRate(() -> {System.out.println(LocalDateTime.now() + "执行任务");}, initialDelay, period, TimeUnit.MILLISECONDS);}//线程池public static ScheduledExecutorService scheduledExecutorService() {return new ScheduledThreadPoolExecutor(1,Executors.defaultThreadFactory(),new ThreadPoolExecutor.CallerRunsPolicy());}
}