Legacy Structured Concurrency

Eric Kolotyluk eric at kolotyluk.net
Wed Nov 30 18:10:52 UTC 2022


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?*/

Cheers, Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20221130/7694d356/attachment.htm>


More information about the loom-dev mailing list