PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Purestorage

Fix Thread-Safe Trigger Synchronization

Last updated: Jun 5, 2026

Quick Overview

This question evaluates understanding of concurrency and thread-safety, focusing on synchronization primitives, race conditions, and memory visibility when coordinating multiple threads for a trigger flag.

  • medium
  • Purestorage
  • Software Engineering Fundamentals
  • Software Engineer

Fix Thread-Safe Trigger Synchronization

Company: Purestorage

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

You are implementing a thread-safe trigger in Python. The trigger has an internal boolean flag, initially `False`. Requirements: - `wait()` blocks until the trigger has fired. - `fire()` sets the flag to `True` and wakes all waiting threads. - If `fire()` is called before `wait()`, future calls to `wait()` should return immediately. - Multiple threads may call `wait()` and `fire()` concurrently. Consider the following follow-up code fragment inside `fire()`: ```python self.lock.acquire() self.lock.release() self.flag = True ``` Is this thread-safe? Explain what can go wrong and show a correct implementation approach.

Quick Answer: This question evaluates understanding of concurrency and thread-safety, focusing on synchronization primitives, race conditions, and memory visibility when coordinating multiple threads for a trigger flag.

Related Interview Questions

  • Design a thread-safe event dispatcher - Purestorage (medium)
Purestorage logo
Purestorage
May 21, 2026, 12:00 AM
Software Engineer
Technical Screen
Software Engineering Fundamentals
3
0

You are implementing a thread-safe trigger in Python.

The trigger has an internal boolean flag, initially False.

Requirements:

  • wait() blocks until the trigger has fired.
  • fire() sets the flag to True and wakes all waiting threads.
  • If fire() is called before wait() , future calls to wait() should return immediately.
  • Multiple threads may call wait() and fire() concurrently.

Consider the following follow-up code fragment inside fire():

self.lock.acquire()
self.lock.release()
self.flag = True

Is this thread-safe? Explain what can go wrong and show a correct implementation approach.

Solution

Show

Submit Your Answer

Sign in to leave a comment

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
PracHub

Master your tech interviews with 8,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.