Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Anmol-Singh-Jaggi/e679bc310e5ea0f9c08917e6df97eda6 to your computer and use it in GitHub Desktop.
Save Anmol-Singh-Jaggi/e679bc310e5ea0f9c08917e6df97eda6 to your computer and use it in GitHub Desktop.
Blog Scheduler approach 2
@Override
void run()
{
while(true)
{
newJob = getNewJobFromCrontabFile() // blocking call
jobQueue.push(newJob)
if(newJob == jobQueue.peek())
{
// The new job is the one that will be scheduled next.
// So wakeup consumer thread so that it does not oversleep.
jobQueueConsumerThread.interrupt()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment