PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Purestorage

Design a thread-safe event dispatcher

Last updated: Apr 26, 2026

Quick Overview

This question evaluates understanding of concurrent programming and thread-safe design, including synchronization primitives, race-condition avoidance, listener lifecycle semantics, and event-delivery guarantees.

  • medium
  • Purestorage
  • Software Engineering Fundamentals
  • Software Engineer

Design a thread-safe event dispatcher

Company: Purestorage

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

## Problem: "Event fire" / event dispatcher with multithreading Design an in-memory event system that supports registering listeners and firing events. ### Core requirements Implement an `EventDispatcher` (or `EventBus`) supporting: - `subscribe(eventType, listener)` - `unsubscribe(eventType, listener)` - `fire(eventType, eventPayload)` — invokes all listeners currently subscribed to `eventType` Where `listener` is a callback/function. ### Follow-ups (multithreading) Assume `subscribe`, `unsubscribe`, and `fire` can be called concurrently from multiple threads. Answer/discuss: 1. What thread-safety guarantees will you provide? (e.g., “listeners registered before fire starts must be called exactly once”, handling concurrent unsubscribe, etc.) 2. How will you avoid race conditions and deadlocks? 3. How will you handle performance trade-offs under high read (fire) vs high write (subscribe/unsubscribe) workloads? 4. Will `fire` be synchronous (caller thread) or asynchronous (thread pool / queue)? How does that change your design? You may state reasonable assumptions (e.g., per-event-type ordering is or isn’t required; at-least-once vs exactly-once delivery within a single process).

Quick Answer: This question evaluates understanding of concurrent programming and thread-safe design, including synchronization primitives, race-condition avoidance, listener lifecycle semantics, and event-delivery guarantees.

Related Interview Questions

  • Fix Thread-Safe Trigger Synchronization - Purestorage (medium)
|Home/Software Engineering Fundamentals/Purestorage

Design a thread-safe event dispatcher

Purestorage logo
Purestorage
Nov 5, 2025, 12:00 AM
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
19
0

Problem: "Event fire" / event dispatcher with multithreading

Design an in-memory event system that supports registering listeners and firing events.

Core requirements

Implement an EventDispatcher (or EventBus) supporting:

  • subscribe(eventType, listener)
  • unsubscribe(eventType, listener)
  • fire(eventType, eventPayload) — invokes all listeners currently subscribed to eventType

Where listener is a callback/function.

Follow-ups (multithreading)

Assume subscribe, unsubscribe, and fire can be called concurrently from multiple threads.

Answer/discuss:

  1. What thread-safety guarantees will you provide? (e.g., “listeners registered before fire starts must be called exactly once”, handling concurrent unsubscribe, etc.)
  2. How will you avoid race conditions and deadlocks?
  3. How will you handle performance trade-offs under high read (fire) vs high write (subscribe/unsubscribe) workloads?
  4. Will fire be synchronous (caller thread) or asynchronous (thread pool / queue)? How does that change your design?

You may state reasonable assumptions (e.g., per-event-type ordering is or isn’t required; at-least-once vs exactly-once delivery within a single process).

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Purestorage•More Software Engineer•Purestorage Software Engineer•Purestorage 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.