Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduleAtFixedRateSkippingToLatest increases the cpu resouces to 95% on 1 hour time shift. #3

Open
Shikari0744 opened this issue Jul 28, 2022 · 0 comments

Comments

@Shikari0744
Copy link

Below code :

private CronScheduler getCronSchedulerExecutor() {
        final ThreadFactory threadFactory = new ThreadFactoryBuilder()
                .setNameFormat("merged-config-%d")
                .setDaemon(true)
                .build();
        Duration syncPeriod = Duration.ofMillis(30_000L);
        CronSchedulerBuilder cronSchedulerBuilder = CronScheduler.newBuilder(syncPeriod);
        cronSchedulerBuilder.setThreadFactory(threadFactory);
        cronSchedulerBuilder.setThreadName("merged-config-refresher");
        return cronSchedulerBuilder.build();
    }
cronScheduler.scheduleAtFixedRateSkippingToLatest(1000, 1800, TimeUnit.MILLISECONDS, runTimeMillis -> {
            runJob(); // some execution
        });

I change the time to 1 hour past and it suddenly spikes the cpu after 30 secs (maybe because my syncPeriod is set to 30secs).
May I know where I am doing wrong ?

~Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant