Class VirtualThreadSynchronizationExamples
java.lang.Object
net.jrodolfo.java_evolution.java24.virtual_thread_synchronization.VirtualThreadSynchronizationExamples
Demonstrates Java 24 synchronization improvements for virtual threads.
The executable example runs a child JVM with virtual-thread scheduler
parallelism set to 1. Many virtual threads block inside
synchronized methods, and another virtual thread must still run to
release them. This demonstrates a behavioral boundary of JEP 491 without
turning the repository into a benchmark.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classResult from running the child JVM probe. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbenefit()Names the practical benefit.Explains the Java 24 runtime goal.pinning()Defines the runtime problem.Source code for the child-JVM probe.runSynchronizedBlockingProbe(Path workspace) Runs the virtual-thread synchronization probe in a child JVM.Explains why the probe limits scheduler parallelism.Explains why synchronized code matters.
-
Constructor Details
-
VirtualThreadSynchronizationExamples
public VirtualThreadSynchronizationExamples()
-
-
Method Details
-
runSynchronizedBlockingProbe
public VirtualThreadSynchronizationExamples.CommandResult runSynchronizedBlockingProbe(Path workspace) throws IOException, InterruptedException Runs the virtual-thread synchronization probe in a child JVM.- Parameters:
workspace- temporary workspace for the generated source file- Returns:
- command result from the child JVM
- Throws:
IOException- when the probe source cannot be written or launchedInterruptedException- when waiting for the child JVM is interrupted
-
probeSource
Source code for the child-JVM probe.- Returns:
- Java source launched by
runSynchronizedBlockingProbe(Path)
-
pinning
-
synchronizedConcern
Explains why synchronized code matters.- Returns:
- a short explanation of the synchronized-code concern
-
java24Improvement
-
benefit
-
schedulerBoundary
Explains why the probe limits scheduler parallelism.- Returns:
- a short explanation
-
successMarker
- Returns:
- the success marker printed by the child JVM probe
-