PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Google

Design a multi-timer using single underlying timer

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to implement timer scheduling, resource multiplexing, and concurrency control using constrained system primitives, testing understanding of timers, event handling, data structures, and correctness under race conditions.

  • medium
  • Google
  • Software Engineering Fundamentals
  • Software Engineer

Design a multi-timer using single underlying timer

Company: Google

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Take-home Project

You are given a `Timer` class that has access to a *single* underlying system timer API that can only keep **one active timer at a time**. ### Underlying single-timer primitives (already available) ```java class Timer { // Schedule ONE timer to fire at `timestamp` (absolute time). // If called again, it overrides/cancels the previously scheduled system timer. private void setTimer(long timestamp); // Called automatically when the currently scheduled system timer expires. private void handleTimer(); // Returns current time as an absolute timestamp (same unit as setTimer). private long getCurrentTime(); // Public API: users can call this to schedule MANY timers. public void setNewTimer(long timestamp); } ``` ### Requirements - Users can only call `setNewTimer(timestamp)`. - `setNewTimer` must support **multiple** outstanding timers. - When any user timer expires, `handleTimer()` should be invoked (once per expired user timer). - You must implement the logic of the four methods so that multiple user timers are correctly managed on top of the single underlying `setTimer`. ### Clarifications you may assume - `timestamp` is an **absolute** time value (e.g., epoch milliseconds) comparable to `getCurrentTime()`. - Multiple user timers may share the same timestamp. - If a timer is set for a time ≤ `getCurrentTime()`, it should fire “immediately” (as soon as the system can schedule it). Discuss data structures, time/space complexity, and important edge cases (e.g., overrides, duplicate timestamps, and concurrency if relevant).

Quick Answer: This question evaluates a candidate's ability to implement timer scheduling, resource multiplexing, and concurrency control using constrained system primitives, testing understanding of timers, event handling, data structures, and correctness under race conditions.

Related Interview Questions

  • Process Sharded Login Logs - Google (medium)
  • Design an ads retrieval service using a heap - Google (easy)
  • Design a waitlist manager - Google (easy)
  • Design an editable sequence with marker - Google (medium)
  • Design a Dormitory Room-Assignment System (OOD) - Google (medium)
|Home/Software Engineering Fundamentals/Google

Design a multi-timer using single underlying timer

Google logo
Google
Dec 4, 2025, 12:00 AM
mediumSoftware EngineerTake-home ProjectSoftware Engineering Fundamentals
10
0

You are given a Timer class that has access to a single underlying system timer API that can only keep one active timer at a time.

Underlying single-timer primitives (already available)

class Timer {
  // Schedule ONE timer to fire at `timestamp` (absolute time).
  // If called again, it overrides/cancels the previously scheduled system timer.
  private void setTimer(long timestamp);

  // Called automatically when the currently scheduled system timer expires.
  private void handleTimer();

  // Returns current time as an absolute timestamp (same unit as setTimer).
  private long getCurrentTime();

  // Public API: users can call this to schedule MANY timers.
  public void setNewTimer(long timestamp);
}

Requirements

  • Users can only call setNewTimer(timestamp) .
  • setNewTimer must support multiple outstanding timers.
  • When any user timer expires, handleTimer() should be invoked (once per expired user timer).
  • You must implement the logic of the four methods so that multiple user timers are correctly managed on top of the single underlying setTimer .

Clarifications you may assume

  • timestamp is an absolute time value (e.g., epoch milliseconds) comparable to getCurrentTime() .
  • Multiple user timers may share the same timestamp.
  • If a timer is set for a time ≤ getCurrentTime() , it should fire “immediately” (as soon as the system can schedule it).

Discuss data structures, time/space complexity, and important edge cases (e.g., overrides, duplicate timestamps, and concurrency if relevant).

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Google•More Software Engineer•Google Software Engineer•Google Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,000+ 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
  • AI Coding 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.