Back to problems

Double-Checked Locking / Locking Correctness in Multithreaded Code

Object-Oriented Programming · Netflix · Medium

In a multithreaded program, design or repair shared-object initialization so that it is thread-safe without introducing unnecessary locking costs. Requirements Implement getInstance() so the object is created when it is first requested and every later call returns that same object. Explain and prevent the well-known hazards of double-checked locking, including memory reordering that could expose an incompletely initialized object. Interface Use this language-neutral…

Checking your access…