Skip to main content

Checkpoint: the named-edge protocol

Challenge on lesson: Checkpoint: The Named-Edge Protocol

Implement static List<String> audit() that runs this exact protocol and returns the audit log: 1. ready latch; worker (virtual thread) publishes List.of("v1","v2") through a SynchronousQueue and counts down ready FIRST (so the put happens after the signal). 2. Main awaits ready, take()s the payload, sets run=false, then counts down done. 3. Worker awaits done, then reads run into its log and finishes. Log entries (in order): "taken:" + payload, "run-seen:" + run, prefixed "worker-started" before anything and "worker-done" after the read. Return the main-side and worker-side logs concatenated: main's entries first ("taken:..."), then worker's ("worker-started", "run-seen:false", "worker-done"). Every await here is a named hb edge — be ready to say which is which.

Difficulty: advanced

Back to lesson: Checkpoint: The Named-Edge Protocol