Is it possible to override the scheduler from user code? i.e. if you wanted to control scheduling yourself for some reason.
I would like an executor that runs all tasks on a single thread and schedules them deterministically for testing.
var myThreadFactory = Thread.builder().virtual(Executors.newSingleThreadExecutor()).factory();
All threads created by this thread factory will be scheduled to the same kernel thread. Executor ste = Executors.newSingleThreadExecutor();
Executor myExecutor = task -> {
if (task instanceof Thread.VirtualThreadTask vtt) System.out.println("Scheduling " + vtt.thread() + " on " + Thread.currentThread());
ste.execute(task);
if (task instanceof Thread.VirtualThreadTask vtt) System.out.println("Descheduled " + vtt.thread() + " from " + Thread.currentThread());
}
var myThreadFactory = Thread.builder().virtual(myExecutor).factory();