BNP Paribas Coding Interview 2027: Multithreading Question Explained

BNP Paribas Coding Interview 2027: Multithreading Question Explained

BNP Paribas Coding Interview 2027: Multithreading Question Explained

For the BNP Paribas coding interview multithreading question — 'Print odd and even numbers in sync using two threads' — the solution is coordination: two threads take turns via a shared lock with wait/notify, so odd prints, hands off, and even prints. Mechanism first, then correctness.

What This Question Assesses in a BNP Paribas Coding Interview Multithreading Question

Multithreading questions are commonly reported by candidates for technology and quantitative developer roles at BNP Paribas. The interviewer is testing whether you understand concurrency primitives or just thread syntax — the hard part is coordination, not creation. Candidates commonly report that interviewers care most about correctness reasoning: can you explain why your solution avoids race conditions and deadlock, not just that it prints numbers?

How to Answer This BNP Paribas Coding Interview Multithreading Question

Explain the mechanism in three steps, then discuss correctness.

  • Step 1 — The problem: Two threads share a counter; without coordination they interleave unpredictably. The task is alternation — odd thread prints 1, even prints 2, odd prints 3 — which requires each thread to wait its turn.
  • Step 2 — The mechanism: Use a shared lock object. Each thread loops: acquire the lock, check whether it is its turn (counter parity), print and increment if so, then notify the other thread and wait if not. Alternatively, two semaphores — one starting with a permit for the odd thread — produce the same alternation more cleanly.
  • Step 3 — Walk the handoff: Trace two iterations aloud: odd thread acquires, prints 1, increments, notifies, waits; even thread wakes, prints 2, increments, notifies, waits. Then address termination: a shared flag or bounded range so both threads exit cleanly.

Example line: "I would use a shared lock with wait and notify: each thread checks the counter's parity under the lock, prints and increments on its turn, then notifies the other and waits — the parity check inside the loop guards against spurious wakeups, and a bounded range gives clean termination."

Common Mistakes With the BNP Paribas Coding Interview Multithreading Question

  • Forgetting the loop around wait. Checking the condition once instead of in a while loop breaks on spurious wakeups — candidates commonly report this as the most probed detail.
  • No termination plan. Threads that print correctly but never exit show incomplete thinking. Always address how the threads finish.
  • Hand-waving the handoff. "They take turns" is not an explanation. Trace the lock acquisition and notification sequence concretely.

Concurrency questions test precision of thought — the interviewer wants to hear you reason about interleavings, not just produce code. Practice explaining the handoff aloud until the wait/notify dance is second nature.

Keep Reading

FAQ

Lock with wait/notify or semaphores? Either is correct. Semaphores express turn-taking more directly; wait/notify shows deeper primitive understanding. Pick one and justify it.

What language should I use? Whichever you are strongest in — Java's synchronized/wait/notify and Python's threading.Condition both demonstrate the concepts. Clarity beats language choice.

Should I write actual code? If the interviewer asks, yes — but lead with the explanation. A correct mechanism described clearly matters more than compilable syntax under pressure.

What follow-ups are common? Extending to N threads, handling spurious wakeups, or comparing with higher-level constructs like blocking queues. The parity-check-in-a-loop answer prepares you for all of these.

Preparing for BNP Paribas's interview? Our 2027 BNP Paribas Online Test and Pymetrics Test Tutorials has practice questions and answers — $79 one-time, instant download.