Skip to content
varokas edited this page May 7, 2014 · 3 revisions

Write a program to take output from 3 processes. Each of them can return true or false. They all have delays of a random between 1 to 3 seconds. Once we collected the votes, print out the verdict.

Expected Output

Vote Result: [true, false, true] 
Consensus: [true]

Point of interests

  • For simple sequential blocking program. It may take up to (3 + 3 + 3) seconds to request all results linearly.
  • This exercise is to find a way to invoke the request in parallel and find consensus at the moment when all results are supplied from the three sources.

Sample Implementation

Clone this wiki locally