Computer programs are typically deterministic, meaning they perform the same actions given the same initial conditions, but non-determinism can arise from environmental inputs or multi-threading. Replay is a system designed to record and replay these non-deterministic behaviors to ensure consistent program execution. It works by capturing all interactions between a program and its environment at the system library call level, allowing it to reproduce the same outputs during replay, even if the original environmental inputs, like files, no longer exist. For multi-threaded programs, Replay employs an ordered lock abstraction to maintain the order of thread execution as it was during the recording, ensuring that shared data is accessed in the same sequence, thus preserving program behavior. The system is flexible enough to record complex programs by requiring slight modifications to the code to leverage ordered locks for thread synchronization. While most system resources can remain unordered to reduce overhead, Replay's approach effectively captures essential interactions, allowing for accurate analysis of program behavior during replay.