← Nvidia questions

Two threads printing even and odd numbers in order

Filed under Nvidia

Write multi-threaded code where one thread prints the even numbers and another prints the odd numbers, so the combined output appears in order (1, 2, 3, ...). Use a mutex and condition variable.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Nvidia questions

Collected from public candidate posts and coding forums. Updated Nov 2026.