Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7001969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:52:12+00:00 2026-05-27T20:52:12+00:00

i came across an interview question which required me to simulate a car race

  • 0

i came across an interview question which required me to simulate a car race .

this was no problem in general , all i did is call the car.Race() method which i built
which loops until it the car reaches its destination ( this is not important !)

what was tricky is to make all 10 threads which the car “raced” on (thread per car )call Car.Race()
simultaneously and not one after the other

  Action<Car,ManualResetEvent> raceDel = (car,handel) =>{
        handel.WaitOne();
        car.Race();
  }

  main()
  {
     ManualResetEvent [] handels = new ManualResetEvent[num_cars];
     Car [] cars = new Car[num_cars];
     for(int i = 0 ; i < num_cars ; i++)
     {
        handels[i] = new ManualResetEvent(false);
        cars[i] = new Car();
        raceDel.BeginInvoke(cars[i],handels[i],null,null);
     } 
      // the question lies here  , i'm looking for something along the lines of 
        WaitHandel.SetAll(handels); // which no such method exists :)

  }   

thread one could start and the car would reach the end of the course before thread 5 even started its execution .

what i did was send a manualresetevent into each thread and called waitOne() on it
the problem now was with what element in the framework could i signal an entire array of ManualResetEvent simultaneously .

WaitHandle has a method WaitHandle.WaitAll(MRE_Array) which would wait for an array of MRE
to call send , i’m looking for something like the opposite which would invoke Set() on an entire array of manualresetevent .

any ideas ?

any work arounds or other synchronization objects that might do the trick would also be well received
thanks in advance
eran.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:52:13+00:00Added an answer on May 27, 2026 at 8:52 pm

    You just need one ManualResetEvent.

    Pass it to all your threads and they can all wait on the same event.

    When the Wait Handle is signalled, all blocked threads are allowed to continue.

    This does not mean they will all continue execution concurrently – that’s up to the OS scheduler – but in practice it will be close, given enough physical cores.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across this post , which reports the following interview question: Given two
I came across this problem during an interview forum., Given an int array which
I came across a interview question which i did not know the answer (
Possible Duplicate: Help with algorithm problem from SPOJ Came across this interview question. Given
I came across this question on an interview questions thread. Here is the question:
I am preparing for my interview and came across this question: Consider that i
I came across this problem while preparing for an interview and curious to know
This is an interview question I came across: find K first digits of the
I recently came across this interview question (posted in a forum somehwere... looks like
I came across this interview question Many irregularly shaped objects are moving in random

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.