Byte Depth
← All tags

#Semaphore

2 articles

Concurrency

Building H2O — Semaphores + CyclicBarrier

Coordinate hydrogen and oxygen threads so they always form complete H2O molecules — never a stray atom — using two semaphores to enforce stoichiometry and a CyclicBarrier to synchronize the triplet.

Aug 10, 2026
ConcurrencyJavaMultithreading

Concurrency

Print FooBar Alternately — Two Approaches

Two threads must alternate printing 'foo' and 'bar' exactly n times each. Compare a synchronized wait/notify approach against a cleaner paired-semaphore solution.

Aug 10, 2026
ConcurrencyJavaMultithreading
© 2026 ByteDepth. All rights reserved.Built with care for curious engineers.