public static void main(String[] args) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime time = now.withHour(6).withMinute(30).withSecond(0).with(DayOfWeek.TUESDAY);
if (now.compareTo(time ) > 0 ){
time = time .plusWeeks(1);
}
Long initialDelay = Duration.between(now,time ).toMillis();
long period = 1000 * 60 * 60 * 24 * 7;
ScheduledExecutorService pool = Executors.newScheduledThreadPool(2);
pool.scheduleAtFixedRate(() -> {
System.out.println("test");
},initialDelay,period,TimeUnit.MILLISECONDS);
pool.scheduleAtFixedRate(() -> {
System.out.println("test1");
},initialDelay,period,TimeUnit.MILLISECONDS);
}