Skip to content

Instantly share code, notes, and snippets.

@godmar
godmar / CommandDemo.java
Created November 4, 2025 03:13
This demo shows how to leverage virtual threads to create deterministic coroutines.
// @author godmar@gmail.com
/* Code demonstration of how to build deterministic coroutines on top of
* virtual threads.
*
* Run with
* java -Djdk.virtualThreadScheduler.parallelism=1 -Djdk.virtualThreadScheduler.maxPoolSize=1 CommandDemo
*/
import java.util.*;
import java.util.concurrent.locks.*;