Legacy Structured Concurrency

David Holmes david.holmes at oracle.com
Thu Dec 1 01:36:14 UTC 2022


On 1/12/2022 4:10 am, Eric Kolotyluk wrote:
> Lately at work I have been working on a piece of Java 8 code (in our Big 
> Ball of Mud) that reminds me of Structured Concurrency.
> 
> It is a concurrent/parallel execution framework that uses
> 
>     final static ExecutorService _executorService =
>     Executors.newFixedThreadPool(50);
> 
>     CompletionService<ObjectNode> completionService = new
>     ExecutorCompletionService(executorService());
> 
> I have since changed this to
> 
>     static ExecutorService _executorService =
>     Executors.newWorkStealingPool();
> 
> Until recently, I was not familiar with CompletionService, but after my 
> recent experiments in Loom Structured Concurrency, it reminded me a 
> little of Structured Concurrency. Certainly not as nice as 
> StructuredTaskScope, but similar in form.
> 
> One of my goals is to refactor our code using Java 19 
> StructuredTaskScope, but that may be a while. In the meantime, I plan to 
> experiment with it.
> 
> /*Having no prior experience with *//*CompletionService*//*I was 
> wondering if anyone knows the history of it, and was is an early attempt 
> at Structured Concurrency?*/

The history is that it stems from Doug Lea's work on concurrency designs 
and patterns, that itself was based on state-of-the-practice for 
concurrent programming back in the 90's. Check out:

https://www.amazon.com/Concurrent-Programming-Java%C2%99-Principles-Pattern/dp/0201310090

I don't know whether to classify it as an early form of "structured 
concurrency".

Cheers,
David

> Cheers, Eric
> 


More information about the loom-dev mailing list