PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Software Engineering Fundamentals/Nuro

Implement a thread-safe periodic job scheduler

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design thread-safe, timer-driven systems, covering synchronization primitives, concurrency control for schedule/cancel APIs, timing assumptions such as a monotonic clock, and handling task overruns in periodic execution.

  • hard
  • Nuro
  • Software Engineering Fundamentals
  • Software Engineer

Implement a thread-safe periodic job scheduler

Company: Nuro

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: Onsite

## Problem: Periodic Job Scheduler (Concurrency) Implement a small in-process **job scheduler** that can run **periodic tasks** (functions/callbacks) at a target frequency. ### Requirements 1. You must support scheduling tasks specified as a function/callback. 2. Each task is **periodic**, e.g. `50 Hz` (50 times per second). You must convert frequency to a period (time interval). 3. Expose two thread-safe APIs: - `schedule(taskFn, frequencyHz) -> jobId` - `cancel(jobId) -> void` 4. The implementation must be **runnable** (not just a dry run): - There is at least **one dedicated worker thread** responsible for executing the tasks. - Another thread may call `schedule()` and `cancel()` concurrently while the worker is running. ### Behavioral expectations / assumptions (state clearly in your implementation) - Use a **monotonic clock** for timing. - Multiple jobs may be scheduled at once. - If a job is cancelled, it should not run again after cancellation takes effect. - Define what happens if a task execution takes longer than its period (e.g., skip missed ticks vs. run immediately to “catch up”). ### What to provide - The scheduler data structures and synchronization strategy. - The worker thread loop logic (sleep/wake strategy). - How cancellation is handled safely under concurrency.

Quick Answer: This question evaluates a candidate's ability to design thread-safe, timer-driven systems, covering synchronization primitives, concurrency control for schedule/cancel APIs, timing assumptions such as a monotonic clock, and handling task overruns in periodic execution.

Nuro logo
Nuro
Jul 31, 2025, 12:00 AM
Software Engineer
Onsite
Software Engineering Fundamentals
15
0

Problem: Periodic Job Scheduler (Concurrency)

Implement a small in-process job scheduler that can run periodic tasks (functions/callbacks) at a target frequency.

Requirements

  1. You must support scheduling tasks specified as a function/callback.
  2. Each task is periodic , e.g. 50 Hz (50 times per second). You must convert frequency to a period (time interval).
  3. Expose two thread-safe APIs:
    • schedule(taskFn, frequencyHz) -> jobId
    • cancel(jobId) -> void
  4. The implementation must be runnable (not just a dry run):
    • There is at least one dedicated worker thread responsible for executing the tasks.
    • Another thread may call schedule() and cancel() concurrently while the worker is running.

Behavioral expectations / assumptions (state clearly in your implementation)

  • Use a monotonic clock for timing.
  • Multiple jobs may be scheduled at once.
  • If a job is cancelled, it should not run again after cancellation takes effect.
  • Define what happens if a task execution takes longer than its period (e.g., skip missed ticks vs. run immediately to “catch up”).

What to provide

  • The scheduler data structures and synchronization strategy.
  • The worker thread loop logic (sleep/wake strategy).
  • How cancellation is handled safely under concurrency.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Nuro•More Software Engineer•Nuro Software Engineer•Nuro Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.