Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The main benefit of structured concurrency is abstraction.  A caller of a method that is invoked to do a task should not care if the method decomposes the task and schedules a million fibers. When the method completes, any fibers scheduled by the method should have terminated.

...

Initial prototype (now obsolete)

In Project Loom, a prototype API has been was developed called FiberScope that is a scope in which fibers are scheduled.  That prototype is currently paused as Project Loom transitions to using java.lang.Thread as the API for fibers/lightweight threads. The prototype will come back, probably in a different form, once the project is over the transition.

Here is a basic example using that prototype:

Code Block
languagejava
     try (var scope = FiberScope.open()) {
         var fiber1 = scope.schedule(task);
         var fiber2 = scope.schedule(task);
     }

...