Home โ€บ Interview Questions โ€บ Task Scheduling, Parallel Execution, Dependency Management

If t1 completes, trigger t2 and t3 in parallel.

๐ŸŸข Easy Conceptual Fresher level
1 Times asked
Jun 2026 Last seen
Jun 2026 First seen

๐Ÿ’ก Model Answer

When t1 finishes, you can trigger t2 and t3 concurrently by using an event-driven approach. In a simple script, you could call t2 and t3 in separate threads or async tasks after t1โ€™s completion. For example, in Python:

python
import threading

def t1():
    # work
    pass

def t2():
    # work
    pass

def t3():
    # work
    pass

# run t1
threading.Thread(target=t1).start()
# after t1 finishes, start t2 and t3
# in real code, use a callback or a future

In production, a workflow engine or message queue (e.g., RabbitMQ, Kafka) can publish a completion event for t1, and consumers for t2 and t3 subscribe to that event, starting them immediately. The key idea is to decouple the trigger from the tasks and allow the system to schedule them in parallel once the prerequisite is satisfied. Complexity is O(1) for the trigger logic, and the parallel execution cost depends on the tasks themselves.

Sign in to unlock the rest of this answer

This answer was generated by AI for study purposes. Use it as a starting point โ€” personalize it with your own experience.

๐ŸŽค Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI โ€” Starts at โ‚น500