Class VirtualThreadSynchronizationExamples

java.lang.Object
net.jrodolfo.java_evolution.java24.virtual_thread_synchronization.VirtualThreadSynchronizationExamples

public class VirtualThreadSynchronizationExamples extends Object
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.

  • 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 launched
      InterruptedException - when waiting for the child JVM is interrupted
    • probeSource

      public String probeSource()
      Source code for the child-JVM probe.
      Returns:
      Java source launched by runSynchronizedBlockingProbe(Path)
    • pinning

      public String pinning()
      Defines the runtime problem.
      Returns:
      a short explanation of pinning
    • synchronizedConcern

      public String synchronizedConcern()
      Explains why synchronized code matters.
      Returns:
      a short explanation of the synchronized-code concern
    • java24Improvement

      public String java24Improvement()
      Explains the Java 24 runtime goal.
      Returns:
      a short explanation
    • benefit

      public String benefit()
      Names the practical benefit.
      Returns:
      a short benefit
    • schedulerBoundary

      public String schedulerBoundary()
      Explains why the probe limits scheduler parallelism.
      Returns:
      a short explanation
    • successMarker

      public String successMarker()
      Returns:
      the success marker printed by the child JVM probe