Skip to content

Add pattern: Timer and TimerTask → ScheduledExecutorService - #211

Merged
brunoborges merged 4 commits into
mainfrom
copilot/timer-task-to-scheduled-executor
Aug 27, 2026
Merged

Add pattern: Timer and TimerTask → ScheduledExecutorService#211
brunoborges merged 4 commits into
mainfrom
copilot/timer-task-to-scheduled-executor

Conversation

Copilot AI commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Adds the "Timer tasks to scheduled executors" concurrency pattern, showing the migration from Timer/TimerTask to ScheduledExecutorService.

Content

  • New pattern file content/concurrency/timer-task-to-scheduled-executor.yaml (difficulty: intermediate, JDK 5+)
  • Spliced into the concurrency navigation chain between lock-free-lazy-init and io/http-client, updating prev/next on both neighbors

Proof

  • proof/concurrency/TimerTaskToScheduledExecutor.java demonstrates the modern code compiles and runs on JDK 25

Translations

  • Partial content translations added for all 13 non-English locales (de, es, pt-BR, zh-CN, ar, fr, ja, ko, bn, it, pl, tr, ru)

Social

  • Appended queue/tweet draft entries via the social queue generator (social/queue.txt, social/tweets.yaml)
// Old
Timer timer = new Timer("refresh-timer");
timer.scheduleAtFixedRate(new TimerTask() {
    @Override public void run() { refresh(); }
}, 0, 60_000);

// Modern
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(this::refresh, 0, 1, TimeUnit.MINUTES);

Copilot AI linked an issue Aug 27, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Replace Timer and TimerTask with ScheduledExecutorService Add pattern: Timer and TimerTask → ScheduledExecutorService Aug 27, 2026
Copilot AI requested a review from brunoborges August 27, 2026 16:03
@brunoborges
brunoborges marked this pull request as ready for review August 27, 2026 16:04
@brunoborges
brunoborges requested a balanced review from Copilot August 27, 2026 16:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the Timer/TimerTask migration pattern to the concurrency catalog.

Changes:

  • Adds pattern content and proof script.
  • Updates navigation and social publishing artifacts.
  • Adds translations for all 13 non-English locales.
Show a summary per file
File Description
content/concurrency/timer-task-to-scheduled-executor.yaml Defines the new pattern.
content/concurrency/lock-free-lazy-init.yaml Links forward to the pattern.
content/io/http-client.yaml Links back to the pattern.
proof/concurrency/TimerTaskToScheduledExecutor.java Provides the compilation proof.
social/queue.txt Queues the pattern for publishing.
social/tweets.yaml Adds its social draft.
translations/content/ar/concurrency/timer-task-to-scheduled-executor.yaml Adds Arabic content.
translations/content/bn/concurrency/timer-task-to-scheduled-executor.yaml Adds Bengali content.
translations/content/de/concurrency/timer-task-to-scheduled-executor.yaml Adds German content.
translations/content/es/concurrency/timer-task-to-scheduled-executor.yaml Adds Spanish content.
translations/content/fr/concurrency/timer-task-to-scheduled-executor.yaml Adds French content.
translations/content/it/concurrency/timer-task-to-scheduled-executor.yaml Adds Italian content.
translations/content/ja/concurrency/timer-task-to-scheduled-executor.yaml Adds Japanese content.
translations/content/ko/concurrency/timer-task-to-scheduled-executor.yaml Adds Korean content.
translations/content/pl/concurrency/timer-task-to-scheduled-executor.yaml Adds Polish content.
translations/content/pt-BR/concurrency/timer-task-to-scheduled-executor.yaml Adds Brazilian Portuguese content.
translations/content/ru/concurrency/timer-task-to-scheduled-executor.yaml Adds Russian content.
translations/content/tr/concurrency/timer-task-to-scheduled-executor.yaml Adds Turkish content.
translations/content/zh-CN/concurrency/timer-task-to-scheduled-executor.yaml Adds Simplified Chinese content.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 19/19 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread content/concurrency/timer-task-to-scheduled-executor.yaml Outdated
Copilot AI and others added 4 commits August 27, 2026 13:20
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@brunoborges
brunoborges force-pushed the copilot/timer-task-to-scheduled-executor branch from a8d0d90 to 1741fcb Compare August 27, 2026 17:21
@brunoborges
brunoborges merged commit 57f7074 into main Aug 27, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

[Pattern] Timer tasks to scheduled executors

3 participants